28 lines
635 B
TypeScript
28 lines
635 B
TypeScript
import i18next from "i18next";
|
|
import config from "@/lib/config";
|
|
import { parse as yamlParse } from "yaml";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const translation = Object.fromEntries(Object.entries(
|
|
yamlParse(readFileSync(`${import.meta.dirname}/../../locales/ja.yaml`, "utf-8"))
|
|
).map(([key, value]) => [
|
|
key,
|
|
typeof value === "string"
|
|
? value.trim()
|
|
: value,
|
|
]));
|
|
|
|
export default async function initI18n() {
|
|
await i18next.init({
|
|
lng: "ja",
|
|
debug: config.debug,
|
|
resources: {
|
|
ja: {
|
|
translation,
|
|
},
|
|
},
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
});
|
|
}; |