Skip to content

Commit 63a92d5

Browse files
committed
ref: json file schemas & structure
1 parent 233869e commit 63a92d5

File tree

14 files changed

+75
-39
lines changed

14 files changed

+75
-39
lines changed

.vscode/schemas/locales.schema.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,48 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
4-
"description": "All locales and translations that are available in BYTM",
4+
"description": "All locales and translations that are available in BYTM.",
55
"patternProperties": {
66
"^[a-z]{2}-[A-Z]{2}$": {
77
"type": "object",
88
"required": ["name", "nameEnglish", "emoji", "userscriptDesc", "authors", "altLocales"],
9-
"description": "Locale code in the format ll-CC (language-country)",
9+
"description": "Main locale code in the format \"ll-CC\" (language-COUNTRY).",
1010
"properties": {
1111
"name": {
1212
"type": "string",
13-
"description": "Name and country of the language, e.g. \"Deutsch (Deutschland)\""
13+
"description": "Native name and country of the language, e.g. \"Deutsch (Deutschland)\"."
1414
},
1515
"nameEnglish": {
1616
"type": "string",
17-
"description": "English name and country of the language, e.g. \"German (Germany)\""
17+
"description": "English name and country of the language, e.g. \"German (Germany)\".",
18+
"pattern": "^.+ \\(.+\\)$"
1819
},
1920
"emoji": {
2021
"type": "string",
2122
"pattern": "^[\uD83C\uDDE6-\uDDFF\uD83C\uDDE6-\uDDFF]{4}$",
22-
"description": "Flag emoji of the country"
23+
"description": "Flag emoji of the country."
2324
},
2425
"userscriptDesc": {
2526
"type": "string",
26-
"description": "Localized userscript description (from \"description\" in package.json)"
27+
"description": "Localized userscript description (from \"description\" in package.json)."
2728
},
2829
"authors": {
2930
"type": "array",
3031
"items": {
3132
"type": "string"
3233
},
33-
"description": "List of authors that contributed to the translation"
34+
"description": "List of authors that contributed to the translation."
3435
},
3536
"altLocales": {
3637
"type": "array",
3738
"items": {
39+
"contains": {
40+
"pattern": "^[a-z]{2}$"
41+
},
3842
"type": "string",
3943
"pattern": "^[a-z]{2}(-[A-Z]{2})?$"
4044
},
41-
"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\"]"
45+
"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\"]."
4246
}
4347
},
4448
"additionalProperties": false

.vscode/schemas/require.schema.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "array",
4-
"description": "Configuration for libraries loaded via @require (only supports UMD bundles or user libraries)",
4+
"description": "Configuration for libraries loaded via @require (only supports UMD bundles or user libraries).",
55
"items": {
66
"type": "object",
77
"required": ["pkgName", "global"],
8-
"description": "Configuration for a library (via UMD bundle or global variable)",
8+
"description": "Configuration for a library (via UMD bundle or global variable).",
99
"properties": {
1010
"pkgName": {
1111
"type": "string",
12-
"description": "Full identifier of the NPM package"
12+
"description": "Full identifier of the NPM package.",
13+
"pattern": "^@?[a-z0-9-_/]+$"
1314
},
1415
"path": {
1516
"type": "string",
16-
"description": "Path to the package's UMD/global bundle file, relative to the library root folder"
17+
"description": "Path to the package's UMD/global bundle file, relative to the library root folder.",
18+
"pattern": "^.+\\.(m|c)?(j|t)sx?$"
1719
},
1820
"global": {
1921
"type": "string",
20-
"description": "Name of the global variable created in the package's UMD/global bundle"
22+
"description": "Name of the global variable created in the package's UMD/global bundle.",
23+
"pattern": "^[$_a-zA-Z][$_a-zA-Z0-9]*$"
2124
}
2225
},
2326
"additionalProperties": false

.vscode/schemas/resources.schema.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"required": ["resources"],
5-
"description": "Contains all resources (images, fonts, stylesheets, etc.) used by BYTM",
5+
"description": "Contains all resources (images, fonts, stylesheets, etc.) used by BYTM.",
66
"properties": {
77
"alwaysExternalAssetPatterns": {
88
"type": "array",
9-
"description": "List of patterns passed to `new RegExp()` that should always be considered external assets (they won't be loaded via @resource)",
9+
"description": "List of patterns passed to `new RegExp()` that should always be considered external assets (they won't be loaded via @resource).",
1010
"items": {
1111
"type": "string",
12-
"format": "regex"
12+
"format": "regex",
13+
"pattern": "^.+$"
1314
}
1415
},
1516
"resources": {
1617
"type": "object",
17-
"description": "Mapping of resource file identifiers and paths",
18+
"description": "Mapping of resource file identifiers and paths.",
1819
"patternProperties": {
1920
"^[a-zA-Z]([a-zA-Z0-9_]+)?-[a-zA-Z0-9-_]+$": {
20-
"description": "Resource key in the format `prefix-resource_name`",
21+
"description": "Resource with a key in the format `prefix-resource_name` and a value that is either a path string or metadata object.",
2122
"oneOf": [
2223
{
2324
"type": "string"
@@ -28,16 +29,16 @@
2829
"properties": {
2930
"path": {
3031
"type": "string",
31-
"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"
32+
"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."
3233
},
3334
"ref": {
3435
"type": "string",
35-
"description": "Branch, tag, or commit SHA to use when fetching the resource. You may make use of $MODE, $BRANCH, $HOST, $BUILD_NUMBER and $UID"
36+
"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."
3637
},
3738
"integrity": {
3839
"type": "boolean",
3940
"default": true,
40-
"description": "Whether to calculate a Subresource Integrity hash for the resource (works with any URLs too)"
41+
"description": "Whether to calculate a Subresource Integrity hash for the resource (works with URLs too)."
4142
}
4243
},
4344
"additionalProperties": false

.vscode/schemas/translation.schema.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"type": "object",
44
"required": ["meta"],
5-
"description": "Mapping of translation keys to strings",
5+
"description": "Mapping of translation keys to strings.",
66
"patternProperties": {
77
"^[a-zA-Z]([a-zA-Z0-9_-]+)?$": {
88
"type": "string",
@@ -12,30 +12,40 @@
1212
"properties": {
1313
"meta": {
1414
"type": "object",
15-
"description": "Metadata about the translation file",
15+
"description": "Metadata about the translation file.",
16+
"required": [
17+
"langName",
18+
"langNameEnglish",
19+
"countryName",
20+
"authors"
21+
],
1622
"properties": {
1723
"base": {
1824
"type": "string",
19-
"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",
25+
"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.",
2026
"pattern": "^[a-z]{2}-[A-Z]{2}$",
2127
"default": "en-US"
2228
},
2329
"langName": {
2430
"type": "string",
25-
"description": "Name of the language in the language itself"
31+
"description": "Name of the language in the language itself."
2632
},
2733
"langNameEnglish": {
2834
"type": "string",
29-
"description": "Name of the language and the country (or locale) in English in the format \"Language (Country or Locale)\"",
35+
"description": "Name of the language and the country (or locale) in English in the format \"Language (Country or Locale)\".",
3036
"pattern": "^[\\w\\s,._\\-&]+ \\([\\w\\s,._\\-&]+\\)$"
3137
},
3238
"countryName": {
3339
"type": "string",
34-
"description": "Name of the country in the language itself"
40+
"description": "Name of the country in the language itself."
3541
},
3642
"authors": {
37-
"type": "string",
38-
"description": "Name(s) of the author and contributors of the translation"
43+
"type": "array",
44+
"description": "Name(s) of the author and contributors of the translation.",
45+
"items": {
46+
"type": "string",
47+
"description": "Name of the author or contributor."
48+
}
3949
}
4050
}
4151
}

assets/translations/de-DE.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "Deutsch",
44
"langNameEnglish": "German (Germany)",
55
"countryName": "Deutschland",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "%1 Einstellungen",
911
"config_menu_title": "%1 - Einstellungen",

assets/translations/en-GB.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"langName": "English",
55
"langNameEnglish": "English (Great Britain)",
66
"countryName": "Great Britain",
7-
"authors": "Sv443"
7+
"authors": [
8+
"Sv443"
9+
]
810
},
911
"feature_category_behavior": "Behaviour",
1012
"vote_ratio_blue_gray": "Blue and grey"

assets/translations/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "English",
44
"langNameEnglish": "English (United States)",
55
"countryName": "United States",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "%1 Configuration",
911
"config_menu_title": "%1 - Configuration",

assets/translations/es-ES.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "Español",
44
"langNameEnglish": "Spanish (Spain)",
55
"countryName": "España",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "Configuración de %1",
911
"config_menu_title": "%1 - Configuración",

assets/translations/fr-FR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "Français",
44
"langNameEnglish": "French (France)",
55
"countryName": "France",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "Configuration de %1",
911
"config_menu_title": "%1 - Configuration",

assets/translations/hi-IN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "हिन्दी",
44
"langNameEnglish": "Hindi (India)",
55
"countryName": "भारत",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "%1 कॉन्फ़िगरेशन",
911
"config_menu_title": "%1 - कॉन्फ़िगरेशन",

assets/translations/ja-JP.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "日本語",
44
"langNameEnglish": "Japanese (Japan)",
55
"countryName": "日本",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "%1 構成",
911
"config_menu_title": "%1 - 構成",

assets/translations/pt-BR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "Português",
44
"langNameEnglish": "Portuguese (Brazil)",
55
"countryName": "Brasil",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "Configuração do %1",
911
"config_menu_title": "%1 - Configuração",

assets/translations/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"langName": "简体中文",
44
"langNameEnglish": "Chinese (Simplified)",
55
"countryName": "中国",
6-
"authors": "Sv443"
6+
"authors": [
7+
"Sv443"
8+
]
79
},
810
"config_menu_option": "%1 配置",
911
"config_menu_title": "%1 - 配置",

contributing.md

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

0 commit comments

Comments
 (0)