mirror of
https://github.com/zadam/trilium.git
synced 2026-02-20 20:54:26 +01:00
fix(standalone): translations not working in prod
Some checks failed
Checks / main (push) Has been cancelled
Deploy Standalone App / Build and Deploy App (push) Has been cancelled
Dev / Test development (push) Has been cancelled
Dev / Build Docker image (push) Has been cancelled
Dev / Check Docker build (Dockerfile) (push) Has been cancelled
Dev / Check Docker build (Dockerfile.alpine) (push) Has been cancelled
Some checks failed
Checks / main (push) Has been cancelled
Deploy Standalone App / Build and Deploy App (push) Has been cancelled
Dev / Test development (push) Has been cancelled
Dev / Build Docker image (push) Has been cancelled
Dev / Check Docker build (Dockerfile) (push) Has been cancelled
Dev / Check Docker build (Dockerfile.alpine) (push) Has been cancelled
This commit is contained in:
parent
e0a23f6b63
commit
d68ada1026
@ -1,9 +1,9 @@
|
||||
import { LOCALE_IDS } from "@triliumnext/commons";
|
||||
import i18next from "i18next";
|
||||
import type i18next from "i18next";
|
||||
import I18NextHttpBackend from "i18next-http-backend";
|
||||
|
||||
export default async function translationProvider(locale: LOCALE_IDS) {
|
||||
await i18next.use(I18NextHttpBackend).init({
|
||||
export default async function translationProvider(i18nextInstance: typeof i18next, locale: LOCALE_IDS) {
|
||||
await i18nextInstance.use(I18NextHttpBackend).init({
|
||||
lng: locale,
|
||||
fallbackLng: "en",
|
||||
ns: "server",
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import { LOCALE_IDS, setDayjsLocale } from "@triliumnext/commons";
|
||||
import i18next from "i18next";
|
||||
import type i18next from "i18next";
|
||||
import { join } from "path";
|
||||
|
||||
import { getResourceDir } from "./utils";
|
||||
|
||||
export async function initializeTranslations(locale: LOCALE_IDS) {
|
||||
export async function initializeTranslations(i18nextInstance: typeof i18next, locale: LOCALE_IDS) {
|
||||
const resourceDir = getResourceDir();
|
||||
const Backend = (await import("i18next-fs-backend/cjs")).default;
|
||||
|
||||
// Initialize translations
|
||||
await i18next.use(Backend).init({
|
||||
await i18nextInstance.use(Backend).init({
|
||||
lng: locale,
|
||||
fallbackLng: "en",
|
||||
ns: "server",
|
||||
|
||||
@ -4,12 +4,12 @@ import options from "./options";
|
||||
import i18next from "i18next";
|
||||
import hidden_subtree from "./hidden_subtree";
|
||||
|
||||
export type TranslationProvider = (locale: LOCALE_IDS) => Promise<void>;
|
||||
export type TranslationProvider = (i18nextInstance: typeof i18next, locale: LOCALE_IDS) => Promise<void>;
|
||||
|
||||
export async function initTranslations(translationProvider: TranslationProvider) {
|
||||
const locale = getCurrentLanguage();
|
||||
|
||||
await translationProvider(locale);
|
||||
await translationProvider(i18next, locale);
|
||||
|
||||
// Initialize dayjs locale.
|
||||
await setDayjsLocale(locale);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user