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