uptime-kuma/src/i18n.js

62 lines
1.5 KiB
JavaScript
Raw Normal View History

import { createI18n } from "vue-i18n/index";
import en from "./languages/en";
2021-10-13 06:44:31 +00:00
const languageList = {
2021-11-26 08:31:19 +00:00
"zh-HK": "繁體中文 (香港)",
"bg-BG": "Български",
"de-DE": "Deutsch (Deutschland)",
"nl-NL": "Nederlands",
"nb-NO": "Norsk",
"es-ES": "Español",
"fa": "Farsi",
"pt-BR": "Português (Brasileiro)",
"fr-FR": "Français (France)",
"hu": "Magyar",
"hr-HR": "Hrvatski",
"it-IT": "Italiano (Italian)",
"id-ID": "Bahasa Indonesia (Indonesian)",
"ja": "日本語",
"da-DK": "Danish (Danmark)",
"sr": "Српски",
"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",
"vi": "Vietnamese",
"zh-TW": "繁體中文 (台灣)"
};
let messages = {
en,
};
2021-11-26 08:31:19 +00:00
for (let lang in languageList) {
messages[lang] = {
languageName: languageList[lang]
};
}
const rtlLangs = ["fa"];
2021-10-04 21:33:52 +00:00
2021-10-07 15:59:15 +00:00
export const currentLocale = () => localStorage.locale
|| languageList[navigator.language] && navigator.language
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|| "en";
export const localeDirection = () => {
2021-10-04 21:33:52 +00:00
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";
};
export const i18n = createI18n({
locale: currentLocale(),
fallbackLocale: "en",
silentFallbackWarn: true,
2021-10-04 21:33:52 +00:00
silentTranslationWarn: true,
2021-11-26 08:31:19 +00:00
messages: messages,
});