Build 29071489

This commit is contained in:
Renan LE CARO 2025-04-10 14:49:28 +02:00
parent 16880533dd
commit 9ae649743c
25 changed files with 367 additions and 10873 deletions

View file

@ -1,13 +1,13 @@
import ar from "./ar.json";
import de from "./de.json";
import en from "./en.json";
import es from "./es.json";
import fr from "./fr.json";
import ko from "./ko.json";
import ru from "./ru.json";
import ur from "./ur.json";
import uz from "./uz.json";
import zh from "./zh.json";
// import ar from "./ar.json";
// import de from "./de.json";
// import es from "./es.json";
// import ko from "./ko.json";
// import ru from "./ru.json";
// import ur from "./ur.json";
// import uz from "./uz.json";
// import zh from "./zh.json";
export const languages = [
{
@ -24,62 +24,62 @@ export const languages = [
levelName: "France",
},
{
text: "عربي",
value: "ar",
strings: ar,
// {
// text: "عربي",
// value: "ar",
// strings: ar,
//
// levelName: "Lebanon",
// },
// {
// text: "Español",
// value: "es",
// strings: es,
//
// levelName: "Spain",
// },
// {
// text: "Русский",
// value: "ru",
// strings: ru,
//
// levelName: "Russia",
// },
levelName: "Lebanon",
},
{
text: "Español",
value: "es",
strings: es,
levelName: "Spain",
},
{
text: "Русский",
value: "ru",
strings: ru,
levelName: "Russia",
},
{
text: "Deutsch",
value: "de",
strings: de,
levelName: "Germany",
},
{
text: "汉语",
value: "zh",
strings: zh,
levelName: "China",
},
{
text: "o'zbek tili",
value: "uz",
strings: uz,
levelName: "Uzbekistan",
},
{
text: "اردو",
value: "ur",
strings: ur,
levelName: "Pakistan",
},
{
text: "한국인",
value: "ko",
strings: ko,
levelName: "Korea",
},
// {
// text: "Deutsch",
// value: "de",
// strings: de,
//
// levelName: "Germany",
// },
// {
// text: "汉语",
// value: "zh",
// strings: zh,
//
// levelName: "China",
// },
// {
// text: "o'zbek tili",
// value: "uz",
// strings: uz,
// levelName: "Uzbekistan",
// },
// {
// text: "اردو",
// value: "ur",
// strings: ur,
//
// levelName: "Pakistan",
// },
// {
// text: "한국인",
// value: "ko",
// strings: ko,
//
// levelName: "Korea",
// },
];
import { getSettingValue } from "../settings";
@ -89,8 +89,13 @@ type translation = { [key in translationKeys]: string };
const languagesMap: Record<string, translation> = {};
languages.forEach((l) => (languagesMap[l.value] = l.strings));
let defaultLang =
[...navigator.languages, navigator.language]
.filter((i) => i)
.map((i) => i.slice(0, 2).toLowerCase())
.find((k) => k in languagesMap) || "en";
export function getCurrentLang() {
return getSettingValue("lang", getFirstBrowserLanguage());
return getSettingValue("lang", defaultLang);
}
export function t(
@ -104,12 +109,3 @@ export function t(
}
return template;
}
function getFirstBrowserLanguage() {
const preferred_languages = [...navigator.languages, navigator.language, "en"]
.filter((i) => i)
.map((i) => i.slice(0, 2).toLowerCase());
const supported = Object.keys(languagesMap);
return preferred_languages.find((k) => supported.includes(k)) || "en";
}