mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 07:37:24 +01:00
31 lines
766 B
TypeScript
31 lines
766 B
TypeScript
import { defineConfig } from 'i18next-cli';
|
|
import { type Plugin, ExtractedKey } from "i18next-cli";
|
|
import { readFile } from "node:fs/promises";
|
|
|
|
const HTMLPlugin: Plugin = {
|
|
name: "html-plugin",
|
|
async onEnd(keys: Map<string, ExtractedKey>) {
|
|
const content = await readFile("src/index.html", "utf-8");
|
|
const matches = content.matchAll(/data-(?:text|tip)="([^"]+)"/g);
|
|
for (const match of matches) {
|
|
const key = match[1];
|
|
keys.set(key, {key, defaultValue: key});
|
|
}
|
|
}
|
|
};
|
|
|
|
export default defineConfig({
|
|
locales: [
|
|
"en",
|
|
"fr"
|
|
],
|
|
extract: {
|
|
input: "src/**/*.{js,ts}",
|
|
output: "public/locales/{{language}}/{{namespace}}.json",
|
|
defaultNS: "lang",
|
|
keySeparator: false
|
|
},
|
|
plugins: [
|
|
HTMLPlugin
|
|
]
|
|
});
|