latest dev + i18n
This commit is contained in:
@@ -28,7 +28,7 @@ const de_DE: Translation = {
|
||||
menu,
|
||||
report,
|
||||
warning,
|
||||
emiji,
|
||||
emoji,
|
||||
};
|
||||
|
||||
export default de_DE;
|
||||
|
||||
@@ -114,6 +114,7 @@ const menu: NonNullable<Translation["menu"]> = {
|
||||
},
|
||||
sub: {
|
||||
profile: "Profil",
|
||||
worlds: "Welt",
|
||||
settings: "Einstellungen",
|
||||
invite: "Einladung",
|
||||
credit: "Über die Karte",
|
||||
|
||||
@@ -113,6 +113,7 @@ const menu: BaseTranslation = {
|
||||
},
|
||||
sub: {
|
||||
profile: "Profile",
|
||||
worlds: "Worlds",
|
||||
settings: "Settings",
|
||||
invite: "Invite",
|
||||
credit: "Credit",
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { detectLocale, navigatorDetector, initLocalStorageDetector } from "typesafe-i18n/detectors";
|
||||
import { FALLBACK_LOCALE } from "../Enum/EnvironmentVariable";
|
||||
import { initI18n, setLocale } from "./i18n-svelte";
|
||||
import { initI18n, setLocale, locale } from "./i18n-svelte";
|
||||
import type { Locales, Translation } from "./i18n-types";
|
||||
import { baseLocale, getTranslationForLocale, locales } from "./i18n-util";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
const fallbackLocale = FALLBACK_LOCALE || baseLocale;
|
||||
const localStorageProperty = "language";
|
||||
@@ -50,3 +51,20 @@ function getDisplayableLocales() {
|
||||
}
|
||||
|
||||
export const displayableLocales = getDisplayableLocales();
|
||||
|
||||
export const i18nJson = (text: string): string => {
|
||||
if (text.trim().startsWith("{")) {
|
||||
try {
|
||||
const textObject = JSON.parse(text);
|
||||
if (textObject[get(locale)]) {
|
||||
return textObject[get(locale)];
|
||||
} else if (Object.keys(textObject).length > 0) {
|
||||
// fallback to first value
|
||||
return textObject[Object.keys(textObject)[0]];
|
||||
}
|
||||
} catch (err) {
|
||||
//
|
||||
}
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user