Add RTL styles. Most of the work is done by the browser 💖

This commit is contained in:
Jed Fox 2020-04-01 13:10:40 -04:00
parent 0e90996715
commit cba0a57ce3
No known key found for this signature in database
GPG key ID: 0B61D18EA54B47E1
11 changed files with 138 additions and 77 deletions

View file

@ -21,7 +21,12 @@ export const languages = [
{ lng: "ko-KR", label: "한국어", data: require("./locales/ko-KR.json") },
{ lng: "zh-TW", label: "繁體中文", data: require("./locales/zh-TW.json") },
{ lng: "zh-CN", label: "简体中文", data: require("./locales/zh-CN.json") },
{ lng: "ar-SA", label: "عربي", data: require("./locales/ar-SA.json") },
{
lng: "ar-SA",
label: "عربي",
data: require("./locales/ar-SA.json"),
rtl: true,
},
];
let currentLanguage = languages[0];
@ -31,6 +36,8 @@ export function setLanguage(newLng: string | undefined) {
currentLanguage =
languages.find((language) => language.lng === newLng) || fallbackLanguage;
document.documentElement.dir = currentLanguage.rtl ? "rtl" : "ltr";
languageDetector.cacheUserLanguage(currentLanguage.lng);
}