From 343616a3f43275405164a165c01a71a35d96de44 Mon Sep 17 00:00:00 2001 From: VampireChicken12 Date: Wed, 29 Nov 2023 19:50:35 -0500 Subject: [PATCH 1/5] ci(semantic release): Add refactor rule --- release.config.cjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/release.config.cjs b/release.config.cjs index 40930543..e1bd9ed8 100644 --- a/release.config.cjs +++ b/release.config.cjs @@ -4,7 +4,13 @@ module.exports = { "@semantic-release/commit-analyzer", { preset: "angular", - releaseRules: [{ type: "translations", release: "patch" }] + releaseRules: [ + { type: "translations", release: "patch" }, + { + type: "refactor", + release: "minor" + } + ] } ], "@semantic-release/release-notes-generator", From a2e0498d252c17189f9c908f817cca16ca813559 Mon Sep 17 00:00:00 2001 From: VampireChicken12 Date: Wed, 29 Nov 2023 22:23:07 -0500 Subject: [PATCH 2/5] build: check for missing translation keys Error if keys are missing --- vite.config.ts | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index d5e866c2..c98d6efc 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,3 +1,5 @@ +import type EnUS from "public/locales/en-US.json"; + import react from "@vitejs/plugin-react-swc"; import { existsSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs"; import { resolve } from "path"; @@ -39,21 +41,26 @@ const emptyOutputFolder = () => { } } }; -function flattenTranslationValues(translationFile: TranslationFile): string[] { +function flattenTranslationValues(translationFile: TranslationFile, parentKey = ""): { keys: string[]; values: string[] } { let values: string[] = []; - + let keys: string[] = []; for (const key in translationFile) { if (["langCode", "langName"].includes(key)) continue; const { [key]: value } = translationFile; + const currentKey = parentKey ? `${parentKey}.${key}` : key; + if (typeof value === "object") { - values = values.concat(flattenTranslationValues(value as TranslationFile)); + const { keys: nestedKeys, values: nestedValues } = flattenTranslationValues(value, currentKey); + values = values.concat(nestedValues); + keys = keys.concat(nestedKeys); } else { values.push(value); + keys.push(currentKey); } } - return values; + return { keys, values }; } function getTranslationFile(translation: AvailableLocales): TranslationFile { const translationFile = readFileSync(`${publicDir}/locales/${translation}.json`, "utf-8"); @@ -74,14 +81,39 @@ function calculateTranslationPercentages() { return translationPercentages; } function calculateTranslationPercentage(englishFile: TranslationFile, translationFile: TranslationFile): number { - const englishValues = flattenTranslationValues(englishFile); - const translationValues = flattenTranslationValues(translationFile); + const { values: englishValues } = flattenTranslationValues(englishFile); + const { values: translationValues } = flattenTranslationValues(translationFile); const differingValues = englishValues.filter((value, index) => value !== translationValues[index]); const translationPercentage = (differingValues.length / englishValues.length) * 100; return Math.floor(translationPercentage); } +function checkForMissingKeys(englishFile: TranslationFile, translationFile: TranslationFile) { + const { keys: englishKeys } = flattenTranslationValues(englishFile); + const { keys: translationKeys } = flattenTranslationValues(translationFile); + if (englishKeys.length !== translationKeys.length) { + const missingKeys = englishKeys.filter((key) => !translationKeys.includes(key)); + const message = `${(translationFile as unknown as EnUS)["langCode"]} is missing ${missingKeys.length} keys\nMissing keys:\n${missingKeys.join( + ", " + )}`; + return message; + } + return false; +} +function checkLocalesForMissingKeys() { + const englishFile = getTranslationFile("en-US"); + const missingKeys = availableLocales + .filter((availableLocales) => availableLocales !== "en-US") + .map((locale) => { + const translationFile = getTranslationFile(locale); + return checkForMissingKeys(englishFile, translationFile); + }) + .filter(Boolean); + if (missingKeys.length) { + throw new Error(missingKeys.join("\n\n")); + } +} function updateTranslationPercentageObject(code: string, updatedObject: Record) { const match = code.match(/export\s+const\s+translationPercentages\s*:\s*Record\s*=\s*({[^}]+});/); @@ -125,6 +157,7 @@ function updateAvailableLocales() { export default function build() { emptyOutputFolder(); updateAvailableLocales(); + checkLocalesForMissingKeys(); updateTranslationPercentages(); return defineConfig({ build: { From d663f4208422d2ef78803cfbb008acfc3677ca2b Mon Sep 17 00:00:00 2001 From: VampireChicken12 Date: Thu, 30 Nov 2023 01:32:07 -0500 Subject: [PATCH 3/5] translations: update strings --- public/locales/en-US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/locales/en-US.json b/public/locales/en-US.json index 15b505f1..48fc0bfa 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -132,7 +132,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -143,7 +143,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, From 6b3993a947e6df213e40cdfb5b2635cc3cd94bc5 Mon Sep 17 00:00:00 2001 From: VampireChicken12 Date: Thu, 30 Nov 2023 10:02:36 -0500 Subject: [PATCH 4/5] translations: update locales and percentages --- public/locales/ca-ES.json | 4 ++-- public/locales/cs-CZ.json | 4 ++-- public/locales/de-DE.json | 4 ++-- public/locales/es-ES.json | 4 ++-- public/locales/fa-IR.json | 4 ++-- public/locales/fr-FR.json | 6 +++--- public/locales/he-IL.json | 4 ++-- public/locales/hi-IN.json | 4 ++-- public/locales/it-IT.json | 4 ++-- public/locales/ja-JP.json | 36 ++++++++++++++++++------------------ public/locales/pl-PL.json | 4 ++-- public/locales/pt-BR.json | 4 ++-- public/locales/tr-TR.json | 2 +- public/locales/zh-CN.json | 4 ++-- src/i18n/index.ts | 2 +- 15 files changed, 45 insertions(+), 45 deletions(-) diff --git a/public/locales/ca-ES.json b/public/locales/ca-ES.json index 090867f4..e6bbbbda 100644 --- a/public/locales/ca-ES.json +++ b/public/locales/ca-ES.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/cs-CZ.json b/public/locales/cs-CZ.json index 45b90562..a87ea1b8 100644 --- a/public/locales/cs-CZ.json +++ b/public/locales/cs-CZ.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/de-DE.json b/public/locales/de-DE.json index 9eff273f..adaa19a0 100644 --- a/public/locales/de-DE.json +++ b/public/locales/de-DE.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/es-ES.json b/public/locales/es-ES.json index e4094a78..1c76dc03 100644 --- a/public/locales/es-ES.json +++ b/public/locales/es-ES.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/fa-IR.json b/public/locales/fa-IR.json index 3b033652..b56bb29c 100644 --- a/public/locales/fa-IR.json +++ b/public/locales/fa-IR.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/fr-FR.json b/public/locales/fr-FR.json index 75d59044..039dfcd5 100644 --- a/public/locales/fr-FR.json +++ b/public/locales/fr-FR.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, @@ -250,4 +250,4 @@ "settingVolume": "Setting volume boost to {{VOLUME_BOOST_AMOUNT}}", "resumingVideo": "Resuming video at {{VIDEO_TIME}}" } -} +} diff --git a/public/locales/he-IL.json b/public/locales/he-IL.json index 7181e3c4..8d3d8b7a 100644 --- a/public/locales/he-IL.json +++ b/public/locales/he-IL.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/hi-IN.json b/public/locales/hi-IN.json index 7923d8bd..61d7b307 100644 --- a/public/locales/hi-IN.json +++ b/public/locales/hi-IN.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/it-IT.json b/public/locales/it-IT.json index c42678e4..e315e382 100644 --- a/public/locales/it-IT.json +++ b/public/locales/it-IT.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/ja-JP.json b/public/locales/ja-JP.json index 7a2eb48f..52a935a5 100644 --- a/public/locales/ja-JP.json +++ b/public/locales/ja-JP.json @@ -151,8 +151,8 @@ }, "holdModifierKey": { "enable": { - "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "title": "キーバインドを押さえるでスクロールホイール音量制御可能にさせる", + "label": "キーバインドに押さえる" }, "optionLabel": "{{KEY}} キー", "select": { @@ -162,48 +162,48 @@ }, "holdRightClick": { "enable": { - "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "title": "右クリックに押さえるでスクロールホイール音量制御可能にする", + "label": "右クリックに押さえるで可能にする" } } }, "automaticQuality": { "title": "自動画質設定", "enable": { - "title": "Automatically adjusts the video quality to the selected level.", + "title": "選択したレベルに合わせて動画の画質を自動的に調整します。", "label": "自動画質調整" }, "select": { "label": "プレイヤーの動画質", - "title": "The quality to set the video to" + "title": "動画の画質に設定する" } }, "playbackSpeed": { - "title": "Playback speed settings", + "title": "再生速度設定", "enable": { - "title": "Sets the video speed to what you choose below", - "label": "Forced playback speed" + "title": "強制再生速度を可能にする", + "label": "強制再生速度" }, "select": { - "label": "Player speed", - "title": "The speed to set the video to" + "label": "動画の再生速度", + "title": "動画の速度に設定する" } }, "volumeBoost": { - "title": "Volume boost settings", + "title": "音量ブーストの設定", "enable": { - "title": "Boosts the volume of the video you're watching", - "label": "Volume boost" + "title": "見ている動画の音量をブーストする", + "label": "音量ブースト" }, "number": { - "label": "Volume boost amount (dB)", - "title": "The amount to boost the volume by" + "label": "デシベル(dB)で音量ブースト", + "title": "音量ブーストの量" } }, "screenshotButton": { - "title": "Screenshot settings", + "title": "スクリーンショット設定", "enable": { - "title": "Adds a button to the player to take a screenshot of the video", + "title": "動画をスクリーンショット撮るするボタンをビデオ・プレーヤーに追加する", "label": "スクリーンショットボタン" }, "selectSaveAs": { diff --git a/public/locales/pl-PL.json b/public/locales/pl-PL.json index 7aab0353..db043864 100644 --- a/public/locales/pl-PL.json +++ b/public/locales/pl-PL.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/pt-BR.json b/public/locales/pt-BR.json index c360c6e3..956674e7 100644 --- a/public/locales/pt-BR.json +++ b/public/locales/pt-BR.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/public/locales/tr-TR.json b/public/locales/tr-TR.json index a2953620..7d44a5e6 100644 --- a/public/locales/tr-TR.json +++ b/public/locales/tr-TR.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} anahtarı", "select": { diff --git a/public/locales/zh-CN.json b/public/locales/zh-CN.json index 3157feb5..3681435b 100644 --- a/public/locales/zh-CN.json +++ b/public/locales/zh-CN.json @@ -152,7 +152,7 @@ "holdModifierKey": { "enable": { "title": "Press a modifier key to enable volume adjustment with the scroll wheel.", - "label": "Hold modifier key" + "label": "Enable when holding modifier key" }, "optionLabel": "{{KEY}} key", "select": { @@ -163,7 +163,7 @@ "holdRightClick": { "enable": { "title": "Hold right click to enable scroll wheel volume control", - "label": "Enable Holding right click" + "label": "Enable when holding right click" } } }, diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 750a9416..fbf3a3d6 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -29,7 +29,7 @@ export const translationPercentages: Record = { "he-IL": 0, "hi-IN": 0, "it-IT": 0, - "ja-JP": 83, + "ja-JP": 100, "pl-PL": 3, "pt-BR": 0, "ru-RU": 100, From b582035b7d61c9fd6804396dfe4ba8be6146baf1 Mon Sep 17 00:00:00 2001 From: VampireChicken12 Date: Thu, 30 Nov 2023 10:04:15 -0500 Subject: [PATCH 5/5] build: change buildEnd to closeBundle --- src/utils/plugins/copy-public.ts | 2 +- src/utils/plugins/make-manifest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/plugins/copy-public.ts b/src/utils/plugins/copy-public.ts index 85ff0383..382f142d 100644 --- a/src/utils/plugins/copy-public.ts +++ b/src/utils/plugins/copy-public.ts @@ -12,7 +12,7 @@ const outDir = resolve(__dirname, "..", "..", "..", outputFolderName); const publicDir = resolve(__dirname, "..", "..", "..", "public"); export default function copyPublic(): PluginOption { return { - buildEnd() { + closeBundle() { for (const browser of browsers) { if (!existsSync(resolve(outDir, browser.name))) { mkdirSync(resolve(outDir, browser.name), { recursive: true }); diff --git a/src/utils/plugins/make-manifest.ts b/src/utils/plugins/make-manifest.ts index 357cc394..2f341877 100644 --- a/src/utils/plugins/make-manifest.ts +++ b/src/utils/plugins/make-manifest.ts @@ -18,7 +18,7 @@ function writeManifest(version: 2 | 3, browserName: string) { } export default function makeManifest(): PluginOption { return { - buildEnd() { + closeBundle() { for (const browser of browsers) { if (!existsSync(resolve(outDir, browser.name))) { mkdirSync(resolve(outDir, browser.name), { recursive: true });