Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
refactor(client): read locales from common instead of going through the server
Elian Dorand212120f9b72
diff --git a/apps/client/src/services/i18n.ts b/apps/client/src/services/i18n.tsindex 5b5f38b762..8790bd6fc9 100644--- a/apps/client/src/services/i18n.ts+++ b/apps/client/src/services/i18n.ts@@ -1,12 +1,9 @@import options from "./options.js";import i18next from "i18next";import i18nextHttpBackend from "i18next-http-backend";-import server from "./server.js";-import { LOCALE_IDS, setDayjsLocale, type Locale } from "@triliumnext/commons";+import { LOCALE_IDS, LOCALES, setDayjsLocale } from "@triliumnext/commons";import { initReactI18next } from "react-i18next";-let locales: Locale[] | null;-/*** A deferred promise that resolves when translations are initialized.*/@@ -15,8 +12,6 @@ export let translationsInitializedPromise = $.Deferred();export async function initLocale() {const locale = ((options.get("locale") as string) || "en") as LOCALE_IDS;- locales = await server.get<Locale[]>("options/locales");-i18next.use(initReactI18next);await i18next.use(i18nextHttpBackend).init({lng: locale,@@ -32,11 +27,7 @@ export async function initLocale() {}export function getAvailableLocales() {- if (!locales) {- throw new Error("Tried to load list of locales, but localization is not yet initialized.")- }-- return locales;+ return LOCALES;}/**@@ -47,7 +38,7 @@ export function getAvailableLocales() {*/export function getLocaleById(localeId: string | null | undefined) {if (!localeId) return null;- return locales?.find((l) => l.id === localeId) ?? null;+ return LOCALES.find((l) => l.id === localeId) ?? null;}export const t = i18next.t;