]> Untitled Git - lemmy-ui.git/blobdiff - src/shared/i18next.ts
reset, merge issues
[lemmy-ui.git] / src / shared / i18next.ts
index 47ca6501542b536b0a2eead58434f2c1f59eda4f..eaedbbf817b4fada361b862b4c7d7c33c26b3083 100644 (file)
@@ -1,5 +1,4 @@
 import i18next, { i18nTyped, Resource } from "i18next";
-import { UserService } from "./services";
 import { ar } from "./translations/ar";
 import { bg } from "./translations/bg";
 import { ca } from "./translations/ca";
@@ -31,7 +30,7 @@ import { sv } from "./translations/sv";
 import { vi } from "./translations/vi";
 import { zh } from "./translations/zh";
 import { zh_Hant } from "./translations/zh_Hant";
-import { isBrowser } from "./utils";
+import { getLanguages } from "./utils";
 
 export const languages = [
   { resource: ar, code: "ar", name: "العربية" },
@@ -74,31 +73,12 @@ function format(value: any, format: any): any {
   return format === "uppercase" ? value.toUpperCase() : value;
 }
 
-class LanguageDetector {
-  static readonly type = "languageDetector";
-
-  detect() {
-    const langs: string[] = [];
-
-    const myLang =
-      UserService.Instance.myUserInfo?.local_user_view.local_user
-        .interface_language ?? "browser";
-
-    if (myLang !== "browser") langs.push(myLang);
-
-    if (isBrowser()) langs.push(...navigator.languages);
-
-    return langs;
-  }
-}
-
-i18next.use(LanguageDetector).init({
+i18next.init({
   debug: false,
   compatibilityJSON: "v3",
-  supportedLngs: languages.map(l => l.code),
-  nonExplicitSupportedLngs: true,
   // load: 'languageOnly',
   // initImmediate: false,
+  lng: getLanguages()[0],
   fallbackLng: "en",
   resources,
   interpolation: { format },