@json-translate/check 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -11
  3. package/package.json +21 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JSON Translate
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,24 +1,80 @@
1
1
  # @json-translate/check
2
2
 
3
- Small CI-friendly validator for JSON locale files.
3
+ Validate translated JSON locale files before they break your app.
4
4
 
5
- It compares translated locale files against a source JSON file and fails when:
5
+ `@json-translate/check` is a small dependency-free CLI for i18n and localization workflows. It compares translated JSON files against a source locale and fails when structure or placeholders drift.
6
6
 
7
- - target JSON cannot be parsed
8
- - keys are missing
9
- - unexpected keys were added
10
- - placeholders drift between source and target strings
7
+ ## Usage
11
8
 
12
9
  ```bash
13
10
  npx @json-translate/check --source locales/en.json --target locales/fr.json --target locales/de.json
14
11
  ```
15
12
 
16
- Example GitHub Actions step:
13
+ You can also pass comma-separated targets:
14
+
15
+ ```bash
16
+ npx @json-translate/check -s locales/en.json -t locales/fr.json,locales/de.json
17
+ ```
18
+
19
+ ## Checks
20
+
21
+ - Target JSON parses successfully
22
+ - Source keys are not missing from target files
23
+ - Unexpected extra keys are reported
24
+ - Placeholders are preserved across source and target strings
25
+
26
+ Placeholder patterns checked:
27
+
28
+ - `{name}`
29
+ - `{{count}}`
30
+ - `${value}`
31
+ - `%s`, `%d`, `%i`, `%f`
32
+
33
+ ## Example Output
34
+
35
+ ```text
36
+ FAIL locales/fr.json
37
+ missing key: nav.save
38
+ extra key: legacy.banner
39
+ placeholder missing at greeting: {name}
40
+ ```
41
+
42
+ ## GitHub Actions
17
43
 
18
44
  ```yaml
19
- - name: Check translated JSON locales
20
- run: npx @json-translate/check --source locales/en.json --target locales/fr.json,locales/de.json
45
+ name: Locale checks
46
+
47
+ on:
48
+ pull_request:
49
+
50
+ jobs:
51
+ json-locales:
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@v4
55
+ - name: Validate translated JSON locale files
56
+ run: npx @json-translate/check --source locales/en.json --target locales/fr.json,locales/de.json
21
57
  ```
22
58
 
23
- For the translation step itself, use JSON Translate:
24
- https://www.json-translate.com/?utm_source=cli&utm_medium=devtool&utm_campaign=json_translate_check
59
+ ## Exit Codes
60
+
61
+ - `0`: no validation issues
62
+ - `1`: validation issues found
63
+ - `2`: usage error or JSON read/parse error
64
+
65
+ ## Where It Fits
66
+
67
+ Use JSON Translate to create draft translations, then run this CLI before merging translated locale files.
68
+
69
+ - Translate JSON files online: https://www.json-translate.com/?utm_source=cli&utm_medium=devtool&utm_campaign=json_translate_check
70
+ - CLI guide: https://www.json-translate.com/json-translate-check
71
+ - i18next workflow: https://www.json-translate.com/translate-i18next-json
72
+
73
+ ## Common Use Cases
74
+
75
+ - i18next locale files
76
+ - next-intl JSON files
77
+ - React Intl message catalogs
78
+ - FormatJS JSON catalogs
79
+ - Vue I18n locale files
80
+ - Chrome extension `_locales/*/messages.json` files
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@json-translate/check",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Validate JSON locale files for missing keys and placeholder drift.",
5
5
  "type": "module",
6
+ "homepage": "https://www.json-translate.com/json-translate-check",
6
7
  "bin": {
7
8
  "json-translate-check": "bin/json-translate-check.mjs"
8
9
  },
10
+ "files": [
11
+ "bin",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
9
15
  "scripts": {
10
16
  "test": "node ./bin/json-translate-check.mjs --help"
11
17
  },
@@ -14,7 +20,20 @@
14
20
  "i18n",
15
21
  "localization",
16
22
  "translation",
17
- "locale"
23
+ "locale",
24
+ "locale-files",
25
+ "i18next",
26
+ "next-intl",
27
+ "react-intl",
28
+ "formatjs",
29
+ "vue-i18n",
30
+ "ci",
31
+ "json-validator",
32
+ "placeholders"
18
33
  ],
34
+ "bugs": {
35
+ "email": "orders@json-translate.com",
36
+ "url": "https://www.json-translate.com/json-translate-check"
37
+ },
19
38
  "license": "MIT"
20
39
  }