瀏覽代碼

ref: json file schemas & structure

Sv443 2 月之前
父節點
當前提交
63a92d5507

+ 12 - 8
.vscode/schemas/locales.schema.json

@@ -1,44 +1,48 @@
 {
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
-  "description": "All locales and translations that are available in BYTM",
+  "description": "All locales and translations that are available in BYTM.",
   "patternProperties": {
     "^[a-z]{2}-[A-Z]{2}$": {
       "type": "object",
       "required": ["name", "nameEnglish", "emoji", "userscriptDesc", "authors", "altLocales"],
-      "description": "Locale code in the format ll-CC (language-country)",
+      "description": "Main locale code in the format \"ll-CC\" (language-COUNTRY).",
       "properties": {
         "name": {
           "type": "string",
-          "description": "Name and country of the language, e.g. \"Deutsch (Deutschland)\""
+          "description": "Native name and country of the language, e.g. \"Deutsch (Deutschland)\"."
         },
         "nameEnglish": {
           "type": "string",
-          "description": "English name and country of the language, e.g. \"German (Germany)\""
+          "description": "English name and country of the language, e.g. \"German (Germany)\".",
+          "pattern": "^.+ \\(.+\\)$"
         },
         "emoji": {
           "type": "string",
           "pattern": "^[\uD83C\uDDE6-\uDDFF\uD83C\uDDE6-\uDDFF]{4}$",
-          "description": "Flag emoji of the country"
+          "description": "Flag emoji of the country."
         },
         "userscriptDesc": {
           "type": "string",
-          "description": "Localized userscript description (from \"description\" in package.json)"
+          "description": "Localized userscript description (from \"description\" in package.json)."
         },
         "authors": {
           "type": "array",
           "items": {
             "type": "string"
           },
-          "description": "List of authors that contributed to the translation"
+          "description": "List of authors that contributed to the translation."
         },
         "altLocales": {
           "type": "array",
           "items": {
+            "contains": {
+              "pattern": "^[a-z]{2}$"
+            },
             "type": "string",
             "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
           },
-          "description": "Alternative locale codes that will be redirected to this locale, e.g. for all German languages: [\"de\", \"de-AT\", \"de-CH\", \"de-LI\", \"de-LU\"]"
+          "description": "Alternative locale codes that will be redirected to this locale, e.g. for all German languages: [\"de\", \"de-AT\", \"de-CH\", \"de-LI\", \"de-LU\"]."
         }
       },
       "additionalProperties": false

+ 8 - 5
.vscode/schemas/require.schema.json

@@ -1,23 +1,26 @@
 {
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "array",
-  "description": "Configuration for libraries loaded via @require (only supports UMD bundles or user libraries)",
+  "description": "Configuration for libraries loaded via @require (only supports UMD bundles or user libraries).",
   "items": {
     "type": "object",
     "required": ["pkgName", "global"],
-    "description": "Configuration for a library (via UMD bundle or global variable)",
+    "description": "Configuration for a library (via UMD bundle or global variable).",
     "properties": {
       "pkgName": {
         "type": "string",
-        "description": "Full identifier of the NPM package"
+        "description": "Full identifier of the NPM package.",
+        "pattern": "^@?[a-z0-9-_/]+$"
       },
       "path": {
         "type": "string",
-        "description": "Path to the package's UMD/global bundle file, relative to the library root folder"
+        "description": "Path to the package's UMD/global bundle file, relative to the library root folder.",
+        "pattern": "^.+\\.(m|c)?(j|t)sx?$"
       },
       "global": {
         "type": "string",
-        "description": "Name of the global variable created in the package's UMD/global bundle"
+        "description": "Name of the global variable created in the package's UMD/global bundle.",
+        "pattern": "^[$_a-zA-Z][$_a-zA-Z0-9]*$"
       }
     },
     "additionalProperties": false

+ 9 - 8
.vscode/schemas/resources.schema.json

@@ -2,22 +2,23 @@
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
   "required": ["resources"],
-  "description": "Contains all resources (images, fonts, stylesheets, etc.) used by BYTM",
+  "description": "Contains all resources (images, fonts, stylesheets, etc.) used by BYTM.",
   "properties": {
     "alwaysExternalAssetPatterns": {
       "type": "array",
-      "description": "List of patterns passed to `new RegExp()` that should always be considered external assets (they won't be loaded via @resource)",
+      "description": "List of patterns passed to `new RegExp()` that should always be considered external assets (they won't be loaded via @resource).",
       "items": {
         "type": "string",
-        "format": "regex"
+        "format": "regex",
+        "pattern": "^.+$"
       }
     },
     "resources": {
       "type": "object",
-      "description": "Mapping of resource file identifiers and paths",
+      "description": "Mapping of resource file identifiers and paths.",
       "patternProperties": {
         "^[a-zA-Z]([a-zA-Z0-9_]+)?-[a-zA-Z0-9-_]+$": {
-          "description": "Resource key in the format `prefix-resource_name`",
+          "description": "Resource with a key in the format `prefix-resource_name` and a value that is either a path string or metadata object.",
           "oneOf": [
             {
               "type": "string"
@@ -28,16 +29,16 @@
               "properties": {
                 "path": {
                   "type": "string",
-                  "description": "Path or URL to the resource. If it starts with /, it's relative to the project root, else it's relative to the assets folder. Query strings and hashes are allowed. You may make use of $MODE, $BRANCH, $HOST, $BUILD_NUMBER and $UID"
+                  "description": "Path or URL to the resource. If it starts with /, it's relative to the project root, else it's relative to the assets folder. Query strings and hashes are allowed. You may make use of the placeholders $MODE, $BRANCH, $HOST, $BUILD_NUMBER and $UID anywhere in the string."
                 },
                 "ref": {
                   "type": "string",
-                  "description": "Branch, tag, or commit SHA to use when fetching the resource. You may make use of $MODE, $BRANCH, $HOST, $BUILD_NUMBER and $UID"
+                  "description": "Git Ref (branch, tag, or commit SHA) to use when fetching the resource from the CDN. Uses the branch and build number from src/constants.ts if not set. You may make use of the placeholders $MODE, $BRANCH, $HOST, $BUILD_NUMBER and $UID anywhere in the string."
                 },
                 "integrity": {
                   "type": "boolean",
                   "default": true,
-                  "description": "Whether to calculate a Subresource Integrity hash for the resource (works with any URLs too)"
+                  "description": "Whether to calculate a Subresource Integrity hash for the resource (works with URLs too)."
                 }
               },
               "additionalProperties": false

+ 18 - 8
.vscode/schemas/translation.schema.json

@@ -2,7 +2,7 @@
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
   "required": ["meta"],
-  "description": "Mapping of translation keys to strings",
+  "description": "Mapping of translation keys to strings.",
   "patternProperties": {
     "^[a-zA-Z]([a-zA-Z0-9_-]+)?$": {
       "type": "string",
@@ -12,30 +12,40 @@
   "properties": {
     "meta": {
       "type": "object",
-      "description": "Metadata about the translation file",
+      "description": "Metadata about the translation file.",
+      "required": [
+        "langName",
+        "langNameEnglish",
+        "countryName",
+        "authors"
+      ],
       "properties": {
         "base": {
           "type": "string",
-          "description": "Optional base locale from which all missing translations are automatically inherited. Must be in the format \"ll-CC\" (language-country), e.g. en-US",
+          "description": "Optional base locale from which all missing translations are automatically inherited. Must be in the format \"ll-CC\" (language-country), e.g. en-US.",
           "pattern": "^[a-z]{2}-[A-Z]{2}$",
           "default": "en-US"
         },
         "langName": {
           "type": "string",
-          "description": "Name of the language in the language itself"
+          "description": "Name of the language in the language itself."
         },
         "langNameEnglish": {
           "type": "string",
-          "description": "Name of the language and the country (or locale) in English in the format \"Language (Country or Locale)\"",
+          "description": "Name of the language and the country (or locale) in English in the format \"Language (Country or Locale)\".",
           "pattern": "^[\\w\\s,._\\-&]+ \\([\\w\\s,._\\-&]+\\)$"
         },
         "countryName": {
           "type": "string",
-          "description": "Name of the country in the language itself"
+          "description": "Name of the country in the language itself."
         },
         "authors": {
-          "type": "string",
-          "description": "Name(s) of the author and contributors of the translation"
+          "type": "array",
+          "description": "Name(s) of the author and contributors of the translation.",
+          "items": {
+            "type": "string",
+            "description": "Name of the author or contributor."
+          }
         }
       }
     }

+ 3 - 1
assets/translations/de-DE.json

@@ -3,7 +3,9 @@
     "langName": "Deutsch",
     "langNameEnglish": "German (Germany)",
     "countryName": "Deutschland",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "%1 Einstellungen",
   "config_menu_title": "%1 - Einstellungen",

+ 3 - 1
assets/translations/en-GB.json

@@ -4,7 +4,9 @@
     "langName": "English",
     "langNameEnglish": "English (Great Britain)",
     "countryName": "Great Britain",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "feature_category_behavior": "Behaviour",
   "vote_ratio_blue_gray": "Blue and grey"

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

@@ -3,7 +3,9 @@
     "langName": "English",
     "langNameEnglish": "English (United States)",
     "countryName": "United States",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "%1 Configuration",
   "config_menu_title": "%1 - Configuration",

+ 3 - 1
assets/translations/es-ES.json

@@ -3,7 +3,9 @@
     "langName": "Español",
     "langNameEnglish": "Spanish (Spain)",
     "countryName": "España",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "Configuración de %1",
   "config_menu_title": "%1 - Configuración",

+ 3 - 1
assets/translations/fr-FR.json

@@ -3,7 +3,9 @@
     "langName": "Français",
     "langNameEnglish": "French (France)",
     "countryName": "France",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "Configuration de %1",
   "config_menu_title": "%1 - Configuration",

+ 3 - 1
assets/translations/hi-IN.json

@@ -3,7 +3,9 @@
     "langName": "हिन्दी",
     "langNameEnglish": "Hindi (India)",
     "countryName": "भारत",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "%1 कॉन्फ़िगरेशन",
   "config_menu_title": "%1 - कॉन्फ़िगरेशन",

+ 3 - 1
assets/translations/ja-JP.json

@@ -3,7 +3,9 @@
     "langName": "日本語",
     "langNameEnglish": "Japanese (Japan)",
     "countryName": "日本",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "%1 構成",
   "config_menu_title": "%1 - 構成",

+ 3 - 1
assets/translations/pt-BR.json

@@ -3,7 +3,9 @@
     "langName": "Português",
     "langNameEnglish": "Portuguese (Brazil)",
     "countryName": "Brasil",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "Configuração do %1",
   "config_menu_title": "%1 - Configuração",

+ 3 - 1
assets/translations/zh-CN.json

@@ -3,7 +3,9 @@
     "langName": "简体中文",
     "langNameEnglish": "Chinese (Simplified)",
     "countryName": "中国",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   "config_menu_option": "%1 配置",
   "config_menu_title": "%1 - 配置",

+ 1 - 1
contributing.md

@@ -56,7 +56,7 @@ To submit a translation, please follow these steps:
     2. Edit it to your translated version and keep the left side of the colon unchanged
     3. Create the mapping in `assets/locales.json` by copying the English one and editing it (please make sure it's alphabetically ordered)
     4. Add the path to the JSON file to `assets/resources.json` by following the format of the others and also alphabetical order
-    5. Add your name to the respective `authors` property in [`assets/locales.json`](./assets/locales.json)
+    5. Add your name to the respective `authors` properties in [`assets/locales.json`](./assets/locales.json) and the translation file
     6. Test your changes by following [this section](#setting-up-the-project-for-local-development), then submit your pull request
 7. Alternatively send it to me directly, [see my homepage](https://sv443.net/) for contact info  
   Make sure you also add your language to the contents of [`assets/locales.json`](./assets/locales.json)