Switch i18next-parser to i18next-cli.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2025-10-01 17:52:33 -07:00
parent c08bbf49ab
commit 5eccd49fef
5 changed files with 1140 additions and 1623 deletions

View File

@@ -1,18 +0,0 @@
import type {UserConfig} from "i18next-parser";
const config: UserConfig = {
createOldCatalogs: false,
defaultValue: (locale, namespace, key, value) =>
locale === "en" ? key! : value!,
indentation: "\t" as unknown as number,
input: ["app/**/*.ts"],
keySeparator: false,
lexers: {
ts: [{lexer: "JavascriptLexer", functions: ["t.__", "t.__mf"]}],
},
locales: ["en"],
namespaceSeparator: false,
output: "public/translations/$LOCALE.json",
sort: (a, b) => (a < b ? -1 : a > b ? 1 : 0),
};
export default config;

14
i18next.config.ts Normal file
View File

@@ -0,0 +1,14 @@
import {defineConfig} from "i18next-cli";
export default defineConfig({
locales: ["en"],
extract: {
input: ["app/**/*.ts"],
output: "public/translations/{{language}}.json",
functions: ["t.__", "t.__mf"],
keySeparator: false,
nsSeparator: false,
sort: (a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0),
indentation: "\t",
},
});

2727
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -178,7 +178,7 @@
"eslint-import-resolver-typescript": "^4.4.4",
"htmlhint": "^1.1.2",
"i18n": "^0.15.1",
"i18next-parser": "^9.3.0",
"i18next-cli": "^1.2.1",
"node-json-db": "^1.3.0",
"p-fifo": "^1.0.0",
"playwright-core": "^1.41.0-alpha-jan-9-2024",

View File

@@ -14,7 +14,7 @@ Within that Weblate project, if you'd like to focus on Zulip Desktop, look
at the **Desktop** component. The other components are for the Zulip web/mobile
app, where translations are also very welcome.
(\*) One file is an exception: `en.json` is maintained by `i18next-parser` as a
(\*) One file is an exception: `en.json` is maintained by `i18next-cli extract` as a
list of (English) messages in the source code, and is used by Weblate as
a list of strings to be translated. It doesn't contain any
translations.