diff --git a/i18next.config.base.ts b/i18next.config.base.ts new file mode 100644 index 00000000..e8a0f780 --- /dev/null +++ b/i18next.config.base.ts @@ -0,0 +1,35 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +import type { defineConfig } from 'i18next-cli'; + +const configBase: Parameters[0] = { + extract: { + input: [ + 'src/renderer/**/*.{ts,tsx}', + 'src/main/**/*.ts', + 'src/common/**/*.ts', + 'src/preload/**/*.ts', + ], + output: 'locales/{{language}}/{{namespace}}.json', + defaultNS: 'translation', + functions: [ + 't', + '*.t', + ], + transComponents: [ + 'Trans', + ], + ignoredAttributes: ['data-testid', 'aria-label', 'role'], + + // Keep in sync between i18next-parser.config.js and i18nCommon.js: + keySeparator: false, + nsSeparator: false, + }, + types: { + input: [ + 'locales/{{language}}/{{namespace}}.json', + ], + output: 'src/types/i18next.d.ts', + }, +}; + +export default configBase; diff --git a/i18next.config.scan.ts b/i18next.config.scan.ts new file mode 100644 index 00000000..03a0c65a --- /dev/null +++ b/i18next.config.scan.ts @@ -0,0 +1,10 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +import { defineConfig } from 'i18next-cli'; + +import configBase from './i18next.config.base.js'; + + +export default defineConfig({ + ...configBase, + locales: ['en'], +}); diff --git a/i18next.config.ts b/i18next.config.ts index 14cda44e..f87aa0c6 100644 --- a/i18next.config.ts +++ b/i18next.config.ts @@ -2,36 +2,9 @@ import { defineConfig } from 'i18next-cli'; import { langNames, mapLang, SupportedLanguage } from './src/common/i18n.js'; - +import configBase from './i18next.config.base.js'; export default defineConfig({ + ...configBase, locales: Object.keys(langNames).map((lng) => mapLang(lng as SupportedLanguage)), - extract: { - input: [ - 'src/renderer/**/*.{ts,tsx}', - 'src/main/**/*.ts', - 'src/common/**/*.ts', - 'src/preload/**/*.ts', - ], - output: 'locales/{{language}}/{{namespace}}.json', - defaultNS: 'translation', - functions: [ - 't', - '*.t', - ], - transComponents: [ - 'Trans', - ], - ignoredAttributes: ['data-testid', 'aria-label', 'role'], - - // Keep in sync between i18next-parser.config.js and i18nCommon.js: - keySeparator: false, - nsSeparator: false, - }, - types: { - input: [ - 'locales/{{language}}/{{namespace}}.json', - ], - output: 'src/types/i18next.d.ts', - }, }); diff --git a/package.json b/package.json index 6a9f0bfa..f3e410ad 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "postinstall": "electron-builder install-app-deps", "version": "tsx script/postversion.mts && git add no.mifi.losslesscut.appdata.xml", "pack-linux": "yarn build && electron-builder --linux", - "scan-i18n": "i18next-cli extract", + "scan-i18n": "i18next-cli -c i18next.config.scan.ts extract", "generate-licenses": "yarn licenses generate-disclaimer > licenses.txt && echo '\n\nffmpeg is licensed under GPL v2+:\n\nhttp://www.gnu.org/licenses/old-licenses/gpl-2.0.html' >> licenses.txt" }, "author": { diff --git a/tsconfig.node.json b/tsconfig.node.json index 1113d8b4..d2814bd2 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -5,7 +5,7 @@ }, "include": [ "electron.vite.config.ts", - "i18next.config.ts", + "i18next.config*.ts", "script/**/*", ], } \ No newline at end of file