ソースを参照

fix: edit locale codes to match bcp 47

Sv443 6 ヶ月 前
コミット
51fb0a4da5

+ 5 - 5
assets/locales.json

@@ -13,11 +13,11 @@
     "emoji": "🇺🇸",
     "userscriptDesc": "Configurable layout and user experience improvements for YouTube Music™ and YouTube™",
     "authors": ["Sv443"],
-    "altLocales": ["en", "en-CA", "en-GB", "en-AU"]
+    "altLocales": ["en", "en-CA", "en-AU"]
   },
-  "en-UK": {
-    "name": "English (United Kingdom)",
-    "nameEnglish": "English (UK)",
+  "en-GB": {
+    "name": "English (Great Britain)",
+    "nameEnglish": "English (GB)",
     "emoji": "🇬🇧",
     "userscriptDesc": "Configurable layout and user experience improvements for YouTube Music™ and YouTube™",
     "authors": ["Sv443"]
@@ -46,7 +46,7 @@
     "authors": ["Sv443"],
     "altLocales": ["hi", "hi-NP"]
   },
-  "ja-JA": {
+  "ja-JP": {
     "name": "日本語 (日本)",
     "nameEnglish": "Japanese",
     "emoji": "🇯🇵",

+ 2 - 2
assets/translations/README.md

@@ -18,7 +18,7 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 | :----: | ------ | --------------- | :------: |
 |  | [`en-US`](./en-US.json) | `324` (default locale) |  |
 | ✅ | [`de-DE`](./de-DE.json) | `324/324` (100%) | ─ |
-|  | [`en-UK`](./en-UK.json) | `324/324` (100%) | `en-US` |
+|  | [`en-GB`](./en-GB.json) | `324/324` (100%) | `en-US` |
 | ✅ | [`es-ES`](./es-ES.json) | `324/324` (100%) | ─ |
 | ✅ | [`fr-FR`](./fr-FR.json) | `324/324` (100%) | ─ |
 | ✅ | [`hi-IN`](./hi-IN.json) | `324/324` (100%) | ─ |
@@ -38,7 +38,7 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 
 <br>
 
-If a translation is based on another translation, that means the keys from the base translation file are automatically applied if they are missing. This is used for locales that are very similar to each other, such as `en-UK` and `en-US`  
+If a translation is based on another translation, that means the keys from the base translation file are automatically applied if they are missing. This is used for locales that are very similar to each other, such as `en-GB` and `en-US`  
 This means to figure out which keys are untranslated, you will need to manually check against the base translation file.
 
 <br>

+ 0 - 0
assets/translations/en-UK.json → assets/translations/en-GB.json


+ 1 - 0
assets/translations/en-US.json

@@ -320,6 +320,7 @@
     "feature_helptext_clearLyricsCache": "If the lyrics that are in the local cache are outdated or you just want to free up some space, you can clear the cache manually by pressing this button.",
     "feature_btn_clearLyricsCache": "Clear cache",
     "feature_btn_clearLyricsCache_running": "Clearing...",
+    "feature_desc_showToastOnLyricsError": "Show a toast notification when an error occurs while looking up the lyrics URL",
     "feature_desc_advancedLyricsFilter": "Experimental: Enable advanced filtering for the lyrics search",
     "feature_helptext_advancedLyricsFilter": "Advanced filtering includes multiple layers of filters that aim to make the lyrics lookups more reliable.\nThese filters may not work well for songs in your language, and songs and artists with less unique titles in general.\nWarning: This feature is still experimental and might not actually perform any better than the default lyrics lookup. Make sure to confirm the prompt that appears if you changed this setting.",
 

+ 0 - 0
assets/translations/ja-JA.json → assets/translations/ja-JP.json


+ 6 - 6
contributing.md

@@ -39,7 +39,7 @@ To submit a translation, please follow these steps:
 1. Copy the contents of the default translation file [`assets/translations/en-US.json`](./assets/translations/en-US.json)
 2. Replace the `en-US` part of the file name with the language code and locale code of the language you want to translate to  
   You can find [a list of these BCP 47 codes here.](https://www.techonthenet.com/js/language_tags.php)  
-  The final locale code should always be in the format `language-COUNTRY` (e.g. `en-US`, `en-UK`, ...)
+  The final locale code should always be in the format `language-COUNTRY` (e.g. `en-US`, `en-GB`, ...)
 3. Translate the strings inside the file, while making sure not to change the keys on the left side of the colon and to preserve the placeholders with the format %n (where n is any number starting at 1).  
   If you don't want to finish it in one go, please remove the extra keys before submitting the file. They can always be added back by running the command `pnpm run tr-format -p -o=language-COUNTRY` (see [this section](#editing-an-existing-translation) for more info).
 4. If you like, you may also create a translation for the [`README-summary.md`](./README-summary.md) file for display on the userscript distribution sites  
@@ -212,7 +212,7 @@ The main files you will be working with are:
   1. Add the locale code and info about the locale to the file [`assets/locales.json`](./assets/locales.json) by following the format of the other entries.  
     Please make sure the alphabetical order is kept.  
     You can find [a list of BCP 47 codes here.](https://www.techonthenet.com/js/language_tags.php)  
-    The final locale code should be in the format `language-COUNTRY` (e.g. `en-US`, `en-UK`, ...)
+    The final locale code should be in the format `language-COUNTRY` (e.g. `en-US`, `en-GB`, ...)
   2. Add a translation file for the locale by following the instructions in the [translations section](#adding-translations-for-a-new-language)
   3. Your locale will be immediately available in the userscript after the next build.
 - Creating a release:
@@ -949,7 +949,7 @@ The usage and example blocks on each are written in TypeScript but can be used i
 > <details><summary><b>Example <i>(click to expand)</i></b></summary>
 > 
 > ```ts
-> unsafeWindow.BYTM.setLocale(myToken, "en-UK");
+> unsafeWindow.BYTM.setLocale(myToken, "en-GB");
 > ```
 > </details>
 
@@ -1015,8 +1015,8 @@ The usage and example blocks on each are written in TypeScript but can be used i
 > <details><summary><b>Example <i>(click to expand)</i></b></summary>
 > 
 > ```ts
-> unsafeWindow.BYTM.hasKeyFor("en-UK", "lyrics_rate_limited"); // true
-> unsafeWindow.BYTM.hasKeyFor("en-UK", "some_key_that_doesnt_exist"); // false
+> unsafeWindow.BYTM.hasKeyFor("en-GB", "lyrics_rate_limited"); // true
+> unsafeWindow.BYTM.hasKeyFor("en-GB", "some_key_that_doesnt_exist"); // false
 > ```
 > </details>
 
@@ -1041,7 +1041,7 @@ The usage and example blocks on each are written in TypeScript but can be used i
 > ```ts
 > const customConfigMenuTitle = document.createElement("div");
 > customConfigMenuTitle.textContent = unsafeWindow.BYTM.t("config_menu_title", "My cool BYTM Plugin");
-> // translated text: "My cool BYTM Plugin - Configuration" (if locale is en-US or en-UK)
+> // translated text: "My cool BYTM Plugin - Configuration" (if locale is en-US or en-GB)
 > ```
 > </details>
 

+ 7 - 1
src/config.ts

@@ -121,8 +121,14 @@ export const migrations: DataMigrationsDict = {
   // 8 -> 9 (v2.2)
   9: (oldData: FeatureConfig) => {
     oldData.locale = oldData.locale.replace("_", "-") as TrLocale;
+    if(oldData.locale as string === "ja-JA")
+      oldData.locale = "ja-JP";
+    if(oldData.locale as string === "en-GB")
+      oldData.locale = "en-GB";
     return useDefaultConfig(oldData, [
-      "autoLikePlayerBarToggleBtn",
+      "showToastOnLyricsError",
+      // TODO(V2.2):
+      // "autoLikePlayerBarToggleBtn",
     ]);
   },
 } as const satisfies DataMigrationsDict;

+ 1 - 1
src/tools/tr-progress-template.md

@@ -18,7 +18,7 @@ To submit or edit a translation, please follow [this guide](../../contributing.m
 
 <br>
 
-If a translation is based on another translation, that means the keys from the base translation file are automatically applied if they are missing. This is used for locales that are very similar to each other, such as `en-UK` and `en-US`  
+If a translation is based on another translation, that means the keys from the base translation file are automatically applied if they are missing. This is used for locales that are very similar to each other, such as `en-GB` and `en-US`  
 This means to figure out which keys are untranslated, you will need to manually check against the base translation file.
 
 <br>