Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions i18next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
]
});
Loading
Loading