mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-05-01 01:09:15 -04:00
Build 29069848
This commit is contained in:
parent
962fd8b0cd
commit
13627b6c09
27 changed files with 17517 additions and 4011 deletions
|
@ -1,10 +1,94 @@
|
|||
import fr from "./fr.json";
|
||||
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";
|
||||
|
||||
export const languages = [
|
||||
{
|
||||
text: "English",
|
||||
value: "en",
|
||||
strings: en,
|
||||
|
||||
levelName: "UK",
|
||||
},
|
||||
{
|
||||
text: "Français",
|
||||
value: "fr",
|
||||
strings: fr,
|
||||
|
||||
levelName: "France",
|
||||
},
|
||||
{
|
||||
text: "عربي",
|
||||
value: "ar",
|
||||
strings: ar,
|
||||
|
||||
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",
|
||||
},
|
||||
];
|
||||
|
||||
import { getSettingValue } from "../settings";
|
||||
|
||||
type translationKeys = keyof typeof en;
|
||||
type translation = { [key in translationKeys]: string };
|
||||
const languages: Record<string, translation> = { fr, en };
|
||||
const languagesMap: Record<string, translation> = {};
|
||||
languages.forEach((l) => (languagesMap[l.value] = l.strings));
|
||||
|
||||
export function getCurrentLang() {
|
||||
return getSettingValue("lang", getFirstBrowserLanguage());
|
||||
}
|
||||
|
@ -14,7 +98,7 @@ export function t(
|
|||
params: { [key: string]: any } = {},
|
||||
): string {
|
||||
const lang = getCurrentLang();
|
||||
let template = languages[lang]?.[key] || languages.en[key];
|
||||
let template = languagesMap[lang]?.[key] || languagesMap.en[key];
|
||||
for (let key in params) {
|
||||
template = template.split("{{" + key + "}}").join(`${params[key]}`);
|
||||
}
|
||||
|
@ -25,7 +109,7 @@ function getFirstBrowserLanguage() {
|
|||
const preferred_languages = [...navigator.languages, navigator.language, "en"]
|
||||
.filter((i) => i)
|
||||
.map((i) => i.slice(0, 2).toLowerCase());
|
||||
const supported = Object.keys(languages);
|
||||
const supported = Object.keys(languagesMap);
|
||||
|
||||
return preferred_languages.find((k) => supported.includes(k)) || "en";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue