소스 검색

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#",
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
   "type": "object",
-  "description": "All locales and translations that are available in BYTM",
+  "description": "All locales and translations that are available in BYTM.",
   "patternProperties": {
   "patternProperties": {
     "^[a-z]{2}-[A-Z]{2}$": {
     "^[a-z]{2}-[A-Z]{2}$": {
       "type": "object",
       "type": "object",
       "required": ["name", "nameEnglish", "emoji", "userscriptDesc", "authors", "altLocales"],
       "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": {
       "properties": {
         "name": {
         "name": {
           "type": "string",
           "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": {
         "nameEnglish": {
           "type": "string",
           "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": {
         "emoji": {
           "type": "string",
           "type": "string",
           "pattern": "^[\uD83C\uDDE6-\uDDFF\uD83C\uDDE6-\uDDFF]{4}$",
           "pattern": "^[\uD83C\uDDE6-\uDDFF\uD83C\uDDE6-\uDDFF]{4}$",
-          "description": "Flag emoji of the country"
+          "description": "Flag emoji of the country."
         },
         },
         "userscriptDesc": {
         "userscriptDesc": {
           "type": "string",
           "type": "string",
-          "description": "Localized userscript description (from \"description\" in package.json)"
+          "description": "Localized userscript description (from \"description\" in package.json)."
         },
         },
         "authors": {
         "authors": {
           "type": "array",
           "type": "array",
           "items": {
           "items": {
             "type": "string"
             "type": "string"
           },
           },
-          "description": "List of authors that contributed to the translation"
+          "description": "List of authors that contributed to the translation."
         },
         },
         "altLocales": {
         "altLocales": {
           "type": "array",
           "type": "array",
           "items": {
           "items": {
+            "contains": {
+              "pattern": "^[a-z]{2}$"
+            },
             "type": "string",
             "type": "string",
             "pattern": "^[a-z]{2}(-[A-Z]{2})?$"
             "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
       "additionalProperties": false

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

@@ -1,23 +1,26 @@
 {
 {
   "$schema": "http://json-schema.org/draft-07/schema#",
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "array",
   "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": {
   "items": {
     "type": "object",
     "type": "object",
     "required": ["pkgName", "global"],
     "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": {
     "properties": {
       "pkgName": {
       "pkgName": {
         "type": "string",
         "type": "string",
-        "description": "Full identifier of the NPM package"
+        "description": "Full identifier of the NPM package.",
+        "pattern": "^@?[a-z0-9-_/]+$"
       },
       },
       "path": {
       "path": {
         "type": "string",
         "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": {
       "global": {
         "type": "string",
         "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
     "additionalProperties": false

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

@@ -2,22 +2,23 @@
   "$schema": "http://json-schema.org/draft-07/schema#",
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
   "type": "object",
   "required": ["resources"],
   "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": {
   "properties": {
     "alwaysExternalAssetPatterns": {
     "alwaysExternalAssetPatterns": {
       "type": "array",
       "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": {
       "items": {
         "type": "string",
         "type": "string",
-        "format": "regex"
+        "format": "regex",
+        "pattern": "^.+$"
       }
       }
     },
     },
     "resources": {
     "resources": {
       "type": "object",
       "type": "object",
-      "description": "Mapping of resource file identifiers and paths",
+      "description": "Mapping of resource file identifiers and paths.",
       "patternProperties": {
       "patternProperties": {
         "^[a-zA-Z]([a-zA-Z0-9_]+)?-[a-zA-Z0-9-_]+$": {
         "^[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": [
           "oneOf": [
             {
             {
               "type": "string"
               "type": "string"
@@ -28,16 +29,16 @@
               "properties": {
               "properties": {
                 "path": {
                 "path": {
                   "type": "string",
                   "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": {
                 "ref": {
                   "type": "string",
                   "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": {
                 "integrity": {
                   "type": "boolean",
                   "type": "boolean",
                   "default": true,
                   "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
               "additionalProperties": false

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

@@ -2,7 +2,7 @@
   "$schema": "http://json-schema.org/draft-07/schema#",
   "$schema": "http://json-schema.org/draft-07/schema#",
   "type": "object",
   "type": "object",
   "required": ["meta"],
   "required": ["meta"],
-  "description": "Mapping of translation keys to strings",
+  "description": "Mapping of translation keys to strings.",
   "patternProperties": {
   "patternProperties": {
     "^[a-zA-Z]([a-zA-Z0-9_-]+)?$": {
     "^[a-zA-Z]([a-zA-Z0-9_-]+)?$": {
       "type": "string",
       "type": "string",
@@ -12,30 +12,40 @@
   "properties": {
   "properties": {
     "meta": {
     "meta": {
       "type": "object",
       "type": "object",
-      "description": "Metadata about the translation file",
+      "description": "Metadata about the translation file.",
+      "required": [
+        "langName",
+        "langNameEnglish",
+        "countryName",
+        "authors"
+      ],
       "properties": {
       "properties": {
         "base": {
         "base": {
           "type": "string",
           "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}$",
           "pattern": "^[a-z]{2}-[A-Z]{2}$",
           "default": "en-US"
           "default": "en-US"
         },
         },
         "langName": {
         "langName": {
           "type": "string",
           "type": "string",
-          "description": "Name of the language in the language itself"
+          "description": "Name of the language in the language itself."
         },
         },
         "langNameEnglish": {
         "langNameEnglish": {
           "type": "string",
           "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,._\\-&]+\\)$"
           "pattern": "^[\\w\\s,._\\-&]+ \\([\\w\\s,._\\-&]+\\)$"
         },
         },
         "countryName": {
         "countryName": {
           "type": "string",
           "type": "string",
-          "description": "Name of the country in the language itself"
+          "description": "Name of the country in the language itself."
         },
         },
         "authors": {
         "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",
     "langName": "Deutsch",
     "langNameEnglish": "German (Germany)",
     "langNameEnglish": "German (Germany)",
     "countryName": "Deutschland",
     "countryName": "Deutschland",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   },
   "config_menu_option": "%1 Einstellungen",
   "config_menu_option": "%1 Einstellungen",
   "config_menu_title": "%1 - Einstellungen",
   "config_menu_title": "%1 - Einstellungen",

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -3,7 +3,9 @@
     "langName": "简体中文",
     "langName": "简体中文",
     "langNameEnglish": "Chinese (Simplified)",
     "langNameEnglish": "Chinese (Simplified)",
     "countryName": "中国",
     "countryName": "中国",
-    "authors": "Sv443"
+    "authors": [
+      "Sv443"
+    ]
   },
   },
   "config_menu_option": "%1 配置",
   "config_menu_option": "%1 配置",
   "config_menu_title": "%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
     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)
     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
     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
     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  
 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)
   Make sure you also add your language to the contents of [`assets/locales.json`](./assets/locales.json)