Skip to content

Commit 6046724

Browse files
committed
chore(i18n): generate JSON Schema for locale files
Generate a JSON Schema from the canonical `en.json` that provides some cool editor DX niceties (autocomplete, typo detection via `additionalProperties: false`) for all i18n locale files. - Add `scripts/generate-i18n-schema.ts` to generate `i18n/schema.json` from en.json. This is a JSON Schema... schema. - Add `"$schema"` reference to this schema to all 27 locale files - Add `pnpm i18n:schema` and run it in the pre-commit hook (updates schema) and in CI (fails if schema is out of date) Note: in the pre-commit hooks I called the node script directly because pnpm adds a ~250ms overhead (on my machine) and it's important for DX for these hooks to be fast.
1 parent 893a3d3 commit 6046724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3330
-7
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,8 @@ jobs:
235235

236236
- name: 🌐 Check for missing or dynamic i18n keys
237237
run: pnpm i18n:report
238+
239+
- name: 🌐 Check i18n schema is up to date
240+
run: |
241+
pnpm i18n:schema
242+
git diff --exit-code i18n/schema.json

i18n/locales/ar-EG.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"$schema": "../schema.json"
3+
}

i18n/locales/ar.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"seo": {
34
"home": {
45
"title": "npmx - متصفح الحزم لسجل npm",

i18n/locales/az-AZ.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"seo": {
34
"home": {
45
"title": "npmx - npm Reyestri üçün Paket Brauzeri",

i18n/locales/cs-CZ.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"seo": {
34
"home": {
45
"title": "npmx - Prohlížeč balíčků pro registr npm",

i18n/locales/de-DE.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"seo": {
34
"home": {
45
"title": "npmx - Paket-Browser für die npm Registry",

i18n/locales/en-GB.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"settings": {
34
"tagline": "customise your npmx experience",
45
"clear_accent": "Clear accent colour"

i18n/locales/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"$schema": "../schema.json"
3+
}

i18n/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"seo": {
34
"home": {
45
"title": "npmx - Package Browser for the npm Registry",

i18n/locales/es-419.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../schema.json",
23
"built_at": "generado {0}",
34
"alt_logo": "logo de npmx",
45
"connector": {

0 commit comments

Comments
 (0)