2022-10-10 16:23:32 +08:00
|
|
|
import { createI18n } from "vue-i18n/dist/vue-i18n.esm-browser.prod.js";
|
2022-12-27 18:11:53 +08:00
|
|
|
import en from "./lang/en.json";
|
2021-10-13 13:44:31 +07:00
|
|
|
|
2021-09-12 19:23:51 +02:00
|
|
|
const languageList = {
|
2023-01-18 19:03:04 +00:00
|
|
|
"ar-SY": "العربية",
|
2022-01-18 08:50:11 +01:00
|
|
|
"cs-CZ": "Čeština",
|
2021-11-26 16:31:19 +08:00
|
|
|
"zh-HK": "繁體中文 (香港)",
|
|
|
|
"bg-BG": "Български",
|
|
|
|
"de-DE": "Deutsch (Deutschland)",
|
2022-12-06 13:43:29 +01:00
|
|
|
"de-CH": "Deutsch (Schweiz)",
|
2021-11-26 16:31:19 +08:00
|
|
|
"nl-NL": "Nederlands",
|
|
|
|
"nb-NO": "Norsk",
|
|
|
|
"es-ES": "Español",
|
2022-06-23 13:29:37 +02:00
|
|
|
"eu": "Euskara",
|
2021-11-26 16:31:19 +08:00
|
|
|
"fa": "Farsi",
|
2022-07-26 02:07:38 +01:00
|
|
|
"pt-PT": "Português (Portugal)",
|
2021-11-26 16:31:19 +08:00
|
|
|
"pt-BR": "Português (Brasileiro)",
|
2023-02-14 20:34:00 +02:00
|
|
|
"fi": "Suomi",
|
2021-11-26 16:31:19 +08:00
|
|
|
"fr-FR": "Français (France)",
|
2023-02-28 12:45:35 -05:00
|
|
|
"he-IL": "עברית",
|
2021-11-26 16:31:19 +08:00
|
|
|
"hu": "Magyar",
|
|
|
|
"hr-HR": "Hrvatski",
|
|
|
|
"it-IT": "Italiano (Italian)",
|
|
|
|
"id-ID": "Bahasa Indonesia (Indonesian)",
|
|
|
|
"ja": "日本語",
|
|
|
|
"da-DK": "Danish (Danmark)",
|
|
|
|
"sr": "Српски",
|
2021-12-14 17:59:26 +01:00
|
|
|
"sl-SI": "Slovenščina",
|
2021-11-26 16:31:19 +08:00
|
|
|
"sr-latn": "Srpski",
|
|
|
|
"sv-SE": "Svenska",
|
|
|
|
"tr-TR": "Türkçe",
|
|
|
|
"ko-KR": "한국어",
|
|
|
|
"ru-RU": "Русский",
|
|
|
|
"zh-CN": "简体中文",
|
|
|
|
"pl": "Polski",
|
|
|
|
"et-EE": "eesti",
|
2022-02-06 11:33:04 +07:00
|
|
|
"vi-VN": "Tiếng Việt",
|
2022-03-31 16:24:28 +08:00
|
|
|
"zh-TW": "繁體中文 (台灣)",
|
2023-03-04 20:49:47 +02:00
|
|
|
"uk-UA": "Українська",
|
2022-05-19 19:44:59 +07:00
|
|
|
"th-TH": "ไทย",
|
2022-10-07 08:55:12 +00:00
|
|
|
"el-GR": "Ελληνικά",
|
2023-01-25 01:58:12 +08:00
|
|
|
"yue": "繁體中文 (廣東話 / 粵語)",
|
2023-02-06 15:21:31 +08:00
|
|
|
"ro": "Limba română",
|
2023-03-15 10:57:47 +04:00
|
|
|
"ur": "Urdu",
|
|
|
|
"ge": "ქართული"
|
2021-11-26 16:31:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
let messages = {
|
2021-09-12 19:23:51 +02:00
|
|
|
en,
|
|
|
|
};
|
|
|
|
|
2021-11-26 16:31:19 +08:00
|
|
|
for (let lang in languageList) {
|
|
|
|
messages[lang] = {
|
|
|
|
languageName: languageList[lang]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-02-17 15:43:49 +05:00
|
|
|
const rtlLangs = [ "fa", "ar-SY", "ur" ];
|
2021-10-04 23:33:52 +02:00
|
|
|
|
2021-10-07 17:59:15 +02:00
|
|
|
export const currentLocale = () => localStorage.locale
|
|
|
|
|| languageList[navigator.language] && navigator.language
|
|
|
|
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|
|
|
|
|| "en";
|
2021-09-26 01:09:00 +03:30
|
|
|
|
|
|
|
export const localeDirection = () => {
|
2021-10-04 23:33:52 +02:00
|
|
|
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";
|
|
|
|
};
|
|
|
|
|
2021-09-12 19:23:51 +02:00
|
|
|
export const i18n = createI18n({
|
2021-09-26 01:09:00 +03:30
|
|
|
locale: currentLocale(),
|
2021-09-12 19:23:51 +02:00
|
|
|
fallbackLocale: "en",
|
|
|
|
silentFallbackWarn: true,
|
2021-10-04 23:33:52 +02:00
|
|
|
silentTranslationWarn: true,
|
2021-11-26 16:31:19 +08:00
|
|
|
messages: messages,
|
2021-09-12 19:23:51 +02:00
|
|
|
});
|