sendou.ink/app/modules/i18n/loader.server.ts
Kalle fd48bced91
Migrate Prettier/Eslint/Stylelint setup to Biome (#1772)
* Initial

* CSS lint

* Test CI

* Add 1v1, 2v2, and 3v3 Tags (#1771)

* Initial

* CSS lint

* Test CI

* Rename step

---------

Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
2024-06-24 13:07:17 +03:00

30 lines
781 B
TypeScript

import { resolve } from "node:path";
import type { EntryContext } from "@remix-run/server-runtime";
import { createInstance } from "i18next";
import type { i18n as i18nType } from "i18next";
import Backend from "i18next-fs-backend";
import { initReactI18next } from "react-i18next";
import { config } from "./config";
import i18next from "./i18next.server";
export async function i18Instance(request: Request, context: EntryContext) {
const instance = createInstance() as i18nType;
const lng = await i18next.getLocale(request);
const ns = i18next.getRouteNamespaces(context);
await instance
.use(initReactI18next)
.use(Backend)
.init({
...config,
lng,
ns,
backend: {
loadPath: resolve("./locales/{{lng}}/{{ns}}.json"),
},
});
return instance;
}