Skip to content

Commit 74d8efe

Browse files
authored
feat: add ignored keys support for json, json5, jsonc, mdx, xcode-xcs… (#1227)
* feat: add ignored keys support for json, json5, jsonc, mdx, xcode-xcstrings, yaml, json-dictionary * chore: add changeset
1 parent e2bf31f commit 74d8efe

File tree

17 files changed

+166
-70
lines changed

17 files changed

+166
-70
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
Add ignoredKeys support

packages/cli/demo/json/en/example.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@
3131
"nested_message": "Nested text"
3232
}
3333
],
34-
"locked_key_1": "This value is locked and should not be changed"
34+
"locked_key_1": "This value is locked and should not be changed",
35+
"ignored_key_1": "This value is ignored and should not appear in target locales"
36+
3537
}

packages/cli/demo/jsonc/en/example.jsonc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616
},
1717
// This key is locked and should not be changed
1818
"locked_key_1": "This value is locked and should not be changed",
19+
// This key is ignored and should be removed from target locales
20+
"ignored_key_1": "This value is ignored and should not appear in target locales",
1921
}

packages/cli/demo/mdx/en/example.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ description: "Our dining experience at the new Italian restaurant downtown"
44
author: "not-localized-author"
55
published: "2024-03-15"
66
rating: 4.5
7+
locked_key_1: "This value should remain unchanged in all locales"
8+
ignored_key_1: "This field should not appear in target locales"
79
---
810

911
# Dinner at Bella Vista
@@ -59,9 +61,3 @@ Our server checked on us regularly, maintaining `service.quality = "excellent"`
5961
|--------|--------|
6062
| Appetizers | `stars(4)` |
6163
| Main dishes | `stars(5)` |
62-
63-
## locked_key_1
64-
65-
This heading is locked and should not be changed.
66-
67-
pattern_1: This paragraph matches the locked pattern and should not be changed.

packages/cli/demo/mdx/es/example.mdx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: Nuestra experiencia gastronómica en el nuevo restaurante italiano
44
author: not-localized-author
55
published: 2024-03-15
66
rating: 4.5
7+
locked_key_1: This value should remain unchanged in all locales
78
---
89

910
# Cena en Bella Vista
@@ -22,9 +23,9 @@ El restaurante tiene un ambiente cálido y acogedor con:
2223

2324
[Reserva tu mesa en línea](https://example.com) o llama durante el horario comercial.
2425

25-
> Consejo: Las reservas de fin de semana se llenan rápidamente, ¡así que reserva con anticipación!
26+
> Consejo: Las reservas de fin de semana se agotan rápidamente, ¡así que reserva con anticipación!
2627
27-
## Altas luces del menú
28+
## Destacados del menú
2829

2930
```javascript
3031
// Restaurant website code - not localized
@@ -45,7 +46,7 @@ function displayMenu(category) {
4546

4647
Comenzamos con la tabla de antipasto y la ensalada de la casa.
4748

48-
La pasta estaba cocinada perfectamente - exactamente `al_dente` como debería ser.
49+
La pasta estaba cocinada perfectamente - exactamente `al_dente` como debe ser.
4950

5051
## Calidad del servicio
5152

@@ -59,9 +60,3 @@ Nuestro camarero nos atendió regularmente, manteniendo `service.quality = "exce
5960
| ------------------ | ------------ |
6061
| Entrantes | `stars(4)` |
6162
| Platos principales | `stars(5)` |
62-
63-
## locked_key_1
64-
65-
This heading is locked and should not be changed.
66-
67-
pattern_1: This paragraph matches the locked pattern and should not be changed.

packages/cli/demo/xcode-xcstrings/example.xcstrings

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,6 @@
4141
}
4242
}
4343
}
44-
},
45-
"es" : {
46-
"variations" : {
47-
"plural" : {
48-
"one" : {
49-
"stringUnit" : {
50-
"state" : "translated",
51-
"value" : "1 artículo"
52-
}
53-
},
54-
"other" : {
55-
"stringUnit" : {
56-
"state" : "translated",
57-
"value" : "%d artículos"
58-
}
59-
},
60-
"zero" : {
61-
"stringUnit" : {
62-
"state" : "translated",
63-
"value" : "Sin artículos"
64-
}
65-
}
66-
}
67-
}
6844
}
6945
}
7046
},
@@ -81,7 +57,7 @@
8157
"es" : {
8258
"stringUnit" : {
8359
"state" : "translated",
84-
"value" : "¡Hola, mundo!"
60+
"value" : "Hello, world!"
8561
}
8662
}
8763
}

packages/cli/demo/yaml/en/example.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ complex_structure:
2727
level_one:
2828
level_two:
2929
message: "Deep nested text"
30-
locked_key_1: "This value is locked and should not be changed"
30+
locked_key_1: "This value is locked and should not be changed"
31+
ignored_key_1: "This value is ignored and should not appear in target locales"

packages/cli/i18n.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,23 @@
2121
"include": ["demo/html/[locale]/*.html"]
2222
},
2323
"json": {
24-
"include": ["demo/json/[locale]/*.json"]
24+
"include": ["demo/json/[locale]/*.json"],
25+
"lockedKeys": ["locked_key_1"],
26+
"ignoredKeys": ["ignored_key_1"]
2527
},
2628
"jsonc": {
27-
"include": ["demo/jsonc/[locale]/*.jsonc"]
29+
"include": ["demo/jsonc/[locale]/*.jsonc"],
30+
"lockedKeys": ["locked_key_1"],
31+
"ignoredKeys": ["ignored_key_1"]
2832
},
2933
"markdown": {
3034
"include": ["demo/markdown/[locale]/*.md"],
3135
"exclude": ["demo/markdown/[locale]/ignored.md"]
3236
},
3337
"mdx": {
34-
"include": ["demo/mdx/[locale]/*.mdx"]
38+
"include": ["demo/mdx/[locale]/*.mdx"],
39+
"lockedKeys": ["meta/locked_key_1"],
40+
"ignoredKeys": ["meta/ignored_key_1"]
3541
},
3642
"po": {
3743
"include": ["demo/po/[locale]/*.po"]
@@ -40,7 +46,9 @@
4046
"include": ["demo/properties/[locale]/*.properties"]
4147
},
4248
"typescript": {
43-
"include": ["demo/typescript/[locale]/*.ts"]
49+
"include": ["demo/typescript/[locale]/*.ts"],
50+
"lockedKeys": ["forms/locked_key_1"],
51+
"ignoredKeys": ["forms/ignored_key_1"]
4452
},
4553
"xcode-strings": {
4654
"include": ["demo/xcode-strings/[locale]/*.strings"]
@@ -49,10 +57,14 @@
4957
"include": ["demo/xcode-stringsdict/[locale]/*.stringsdict"]
5058
},
5159
"xcode-xcstrings": {
52-
"include": ["demo/xcode-xcstrings/*.xcstrings"]
60+
"include": ["demo/xcode-xcstrings/*.xcstrings"],
61+
"lockedKeys": ["api_key"],
62+
"ignoredKeys": ["item_count"]
5363
},
5464
"yaml": {
55-
"include": ["demo/yaml/[locale]/*.yml"]
65+
"include": ["demo/yaml/[locale]/*.yml"],
66+
"lockedKeys": ["locked_key_1"],
67+
"ignoredKeys": ["ignored_key_1"]
5668
},
5769
"yaml-root-key": {
5870
"include": ["demo/yaml-root-key/[locale]/*.yml"]

packages/cli/i18n.lock

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ checksums:
378378
key4: 10627fcc465897af0f5e1bba042685f9
379379
key5: b328c432cee108a87a92f05258b6a651
380380
key6/key7: 9da96ad1d5c544070ac5e268de77fb48
381-
locked_key_1: 73fc105de1aefc3f0a97d187a80cf0a4
382381
1d941f3fcb422e74ccb8adb0f899afad:
383382
md-section-0: d53f61b8c8922fb62d9df5678d9b44a8
384383
md-section-1: 98aec271471bedce0e12b530c7060827
@@ -437,7 +436,6 @@ checksums:
437436
config/theme/primary: 7535a3779d6934ea8ecf18f5cb5b93fd
438437
mixed_array/0: 001b5b003d96c133534f5907abffdf77
439438
mixed_array/3/nested_message: 5f0782dfc5993e99890c0475bc295a30
440-
locked_key_1: 73fc105de1aefc3f0a97d187a80cf0a4
441439
92012b8cd020f7be41f85bab88f5d251:
442440
welcome_message: 9c56d00796c3c7facba6a25275de5b7b
443441
login_button: 0029e5a35676c0051e761fcd046ef9ee
@@ -489,12 +487,7 @@ checksums:
489487
forms/messageLabel: 1e460d0909502d0e94b9be562643af0d
490488
forms/submitButton: 487177489aafc9c0243c57ef3850a2d9
491489
forms/successMessage: a0a7aa980dffa31d4d194af718a917b3
492-
forms/locked_key_1: 73fc105de1aefc3f0a97d187a80cf0a4
493-
forms/ignored_key_1: d88a7aa6c5661ca901ee0f4cb51e3a0d
494490
11b3ea8486d8e09d2bf06db1811e0490:
495-
item_count/one: d25ee41f72a2ea94ebc6debc85b9e573
496-
item_count/other: ecb3f18dc6a5e7b3e1d9afe7ef62cf07
497-
item_count/zero: 955c31a42e9ff663a49e69e944c8c537
498491
welcome_message: 0468579ef2fbc83c9d520c2f2f1c5059
499492
ae4fae82257615e5c22b34de033c7eeb:
500493
welcome_message: 0468579ef2fbc83c9d520c2f2f1c5059
@@ -520,7 +513,6 @@ checksums:
520513
product/features/0: c916ba887951a02793ff851853fd964f
521514
product/features/1: 1c60a04d6890c6ec910a7f2e6ec0ae7b
522515
complex_structure/level_one/level_two/message: b53034560bf657106e5aaea9160e357e
523-
locked_key_1: 73fc105de1aefc3f0a97d187a80cf0a4
524516
32707dfb19e6dfad9a1af32087b6f9f3:
525517
welcome_message/NSStringLocalizedFormatKey: f142738692c027d95dce521e7cb29c82
526518
welcome_message/user_count/NSStringFormatSpecTypeKey: 8cc03ef30ad5b2d8e27f3612627d932e
@@ -604,7 +596,4 @@ checksums:
604596
content/16: 14f593e7cf3b3df84a21e17db318912e
605597
content/17: 5f42d26a42aa29be063019eea27ad07c
606598
content/18: 48bb7e89e72d68d6de12f5cdac64fc18
607-
content/19: 1639b9ef57bf363e04293e27d1c13952
608-
content/20: bb1c8d22064f7af4879c69d444e6e769
609-
content/21: 98dd186e756ea72c0bdb6e0fe2ae0cbd
610599
e6d8e00051ea40ca138a9549ed52e1c6: {}

packages/cli/src/cli/cmd/run/_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type CmdRunTask = {
3131
injectLocale: string[];
3232
lockedKeys: string[];
3333
lockedPatterns: string[];
34+
ignoredKeys: string[];
3435
onlyKeys: string[];
3536
formatter?: "prettier" | "biome";
3637
};

0 commit comments

Comments
 (0)