Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: update i18nKeysPlugin to accept strict mode and add new translation keys

Tonhod28e2ef3d7ba
diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts
index 731d627f..7eb3d691 100644
--- a/src/lib/i18n/keys.ts
+++ b/src/lib/i18n/keys.ts
@@ -313,6 +313,7 @@ export type TranslationKeys =
| 'omnibox.fmt_video'
| 'omnibox.formats_error'
| 'omnibox.formats_merge_note'
+ | 'omnibox.formats_presets_label'
| 'omnibox.go_to_hotmart'
| 'omnibox.hide_all_formats'
| 'omnibox.hide_formats'
@@ -324,6 +325,9 @@ export type TranslationKeys =
| 'omnibox.options'
| 'omnibox.placeholder'
| 'omnibox.preparing'
+ | 'omnibox.preset_best'
+ | 'omnibox.preset_custom'
+ | 'omnibox.preset_music'
| 'omnibox.quality'
| 'omnibox.quality_1080p'
| 'omnibox.quality_360p'
diff --git a/vite.config.js b/vite.config.js
index fe14cb9d..4efae78d 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -27,7 +27,7 @@ function getVersion() {
}
}
-function i18nKeysPlugin() {
+function i18nKeysPlugin({ strict } = { strict: false }) {
return {
name: "omniget-i18n-keys",
buildStart() {
@@ -35,14 +35,13 @@ function i18nKeysPlugin() {
if (!existsSync(script)) {
return;
}
- const strict = process.env.OMNIGET_I18N_STRICT !== "0";
const args = strict ? [script, "--strict"] : [script];
const result = spawnSync(process.execPath, args, {
cwd: configDir,
stdio: "inherit",
});
if (result.status !== 0) {
- this.error(
+ throw new Error(
`generate-i18n-keys.js exited with code ${result.status}. ` +
`Fix locale keys or set OMNIGET_I18N_STRICT=0 to bypass.`,
);
@@ -51,12 +50,15 @@ function i18nKeysPlugin() {
};
}
-// https://vite.dev/config/
-export default defineConfig(async () => {
+export default defineConfig(async ({ command }) => {
const gitInfo = getGitInfo();
+ const isBuild = command === "build";
+ const strictI18n =
+ process.env.OMNIGET_I18N_STRICT === "1" ||
+ (isBuild && process.env.OMNIGET_I18N_STRICT !== "0");
return {
- plugins: [i18nKeysPlugin(), sveltekit()],
+ plugins: [i18nKeysPlugin({ strict: strictI18n }), sveltekit()],
define: {
__COMMIT_HASH__: JSON.stringify(gitInfo.hash),