Skip to content

Commit 2aedf3b

Browse files
committed
feat(cli): add .stringsdict support
1 parent ca9e20e commit 2aedf3b

14 files changed

Lines changed: 326 additions & 137 deletions

File tree

.changeset/itchy-lies-hang.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@replexica/spec": minor
3+
"@replexica/cli": minor
4+
"replexica": minor
5+
---
6+
7+
added support for .stringsdict
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"greeting" = "Hello!";
2+
"welcome_user" = "Welcome, %@!";
3+
"complex_format" = "User %1$@ has %2$lld points and $%3$.2f balance";
4+
"date_format" = "Today is %@";
5+
"multiline_html" = "This is a <b>multiline</b> string with:\n• HTML tags\n• Special characters: ©®™\n• A <a href=\"https://example.com\">link</a>";
6+
7+
"items_count_zero" = "No items";
8+
"items_count_one" = "One item";
9+
"items_count_two" = "Two items";
10+
"items_count_few" = "%lld items";
11+
"items_count_many" = "%lld items";
12+
"items_count_other" = "%lld items";
13+
14+
"days_until_event_zero" = "The event is today!";
15+
"days_until_event_one" = "The event is tomorrow!";
16+
"days_until_event_two" = "The event is in two days";
17+
"days_until_event_few" = "The event is in %lld days";
18+
"days_until_event_many" = "The event is in %lld days";
19+
"days_until_event_other" = "The event is in %lld days";
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"greeting" = "¡Hola!";
2+
"welcome_user" = "¡Bienvenido, %@!";
3+
"complex_format" = "El usuario %1$@ tiene %2$lld puntos y un saldo de $%3$.2f";
4+
"date_format" = "Hoy es %@";
5+
"multiline_html" = "Esto es una cadena <b>multilínea</b> con:\n• Etiquetas HTML\n• Caracteres especiales: ©®™\n• Un <a href=\"https://example.com\">enlace</a>";
6+
"items_count_zero" = "No hay elementos";
7+
"items_count_one" = "Un elemento";
8+
"items_count_two" = "Dos elementos";
9+
"items_count_few" = "%lld elementos";
10+
"items_count_many" = "%lld elementos";
11+
"items_count_other" = "%lld elementos";
12+
"days_until_event_zero" = "¡El evento es hoy!";
13+
"days_until_event_one" = "¡El evento es mañana!";
14+
"days_until_event_two" = "El evento es en dos días";
15+
"days_until_event_few" = "El evento es en %lld días";
16+
"days_until_event_many" = "El evento es en %lld días";
17+
"days_until_event_other" = "El evento es en %lld días";
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>items_count</key>
6+
<dict>
7+
<key>NSStringLocalizedFormatKey</key>
8+
<string>%#@items@</string>
9+
<key>items</key>
10+
<dict>
11+
<key>NSStringFormatSpecTypeKey</key>
12+
<string>NSStringPluralRuleType</string>
13+
<key>NSStringFormatValueTypeKey</key>
14+
<string>lld</string>
15+
<key>zero</key>
16+
<string>No items</string>
17+
<key>one</key>
18+
<string>One item</string>
19+
<key>two</key>
20+
<string>Two items</string>
21+
<key>few</key>
22+
<string>%lld items</string>
23+
<key>many</key>
24+
<string>%lld items</string>
25+
<key>other</key>
26+
<string>%lld items</string>
27+
</dict>
28+
</dict>
29+
<key>days_until_event</key>
30+
<dict>
31+
<key>NSStringLocalizedFormatKey</key>
32+
<string>%#@days@</string>
33+
<key>days</key>
34+
<dict>
35+
<key>NSStringFormatSpecTypeKey</key>
36+
<string>NSStringPluralRuleType</string>
37+
<key>NSStringFormatValueTypeKey</key>
38+
<string>lld</string>
39+
<key>zero</key>
40+
<string>The event is today!</string>
41+
<key>one</key>
42+
<string>The event is tomorrow!</string>
43+
<key>two</key>
44+
<string>The event is in two days</string>
45+
<key>few</key>
46+
<string>The event is in %lld days</string>
47+
<key>many</key>
48+
<string>The event is in %lld days</string>
49+
<key>other</key>
50+
<string>The event is in %lld days</string>
51+
</dict>
52+
</dict>
53+
<key>greeting</key>
54+
<string>Hello!</string>
55+
<key>welcome_user</key>
56+
<string>Welcome, %@!</string>
57+
<key>complex_format</key>
58+
<string>User %1$@ has %2$lld points and $%3$.2f balance</string>
59+
<key>date_format</key>
60+
<string>Today is %@</string>
61+
<key>multiline_html</key>
62+
<string>This is a &lt;b&gt;multiline&lt;/b&gt; string with:
63+
• HTML tags
64+
• Special characters: ©®™
65+
• A &lt;a href="https://example.com"&gt;link&lt;/a&gt;</string>
66+
</dict>
67+
</plist>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>items_count</key>
6+
<dict>
7+
<key>NSStringLocalizedFormatKey</key>
8+
<string>%#@items@</string>
9+
<key>items</key>
10+
<dict>
11+
<key>NSStringFormatSpecTypeKey</key>
12+
<string>NSStringPluralRuleType</string>
13+
<key>NSStringFormatValueTypeKey</key>
14+
<string>lld</string>
15+
<key>zero</key>
16+
<string>No hay elementos</string>
17+
<key>one</key>
18+
<string>Un elemento</string>
19+
<key>two</key>
20+
<string>Dos elementos</string>
21+
<key>few</key>
22+
<string>%lld elementos</string>
23+
<key>many</key>
24+
<string>%lld elementos</string>
25+
<key>other</key>
26+
<string>%lld elementos</string>
27+
</dict>
28+
</dict>
29+
<key>days_until_event</key>
30+
<dict>
31+
<key>NSStringLocalizedFormatKey</key>
32+
<string>%#@days@</string>
33+
<key>days</key>
34+
<dict>
35+
<key>NSStringFormatSpecTypeKey</key>
36+
<string>NSStringPluralRuleType</string>
37+
<key>NSStringFormatValueTypeKey</key>
38+
<string>lld</string>
39+
<key>zero</key>
40+
<string>¡El evento es hoy!</string>
41+
<key>one</key>
42+
<string>¡El evento es mañana!</string>
43+
<key>two</key>
44+
<string>El evento es en dos días</string>
45+
<key>few</key>
46+
<string>El evento es en %lld días</string>
47+
<key>many</key>
48+
<string>El evento es en %lld días</string>
49+
<key>other</key>
50+
<string>El evento es en %lld días</string>
51+
</dict>
52+
</dict>
53+
<key>greeting</key>
54+
<string>¡Hola!</string>
55+
<key>welcome_user</key>
56+
<string>¡Bienvenido, %@!</string>
57+
<key>complex_format</key>
58+
<string>El usuario %1$@ tiene %2$lld puntos y un saldo de $%3$.2f</string>
59+
<key>date_format</key>
60+
<string>Hoy es %@</string>
61+
<key>multiline_html</key>
62+
<string>Esto es una cadena &lt;b&gt;multilínea&lt;/b&gt; con:
63+
• Etiquetas HTML
64+
• Caracteres especiales: ©®™
65+
• Un &lt;a href="https://example.com"&gt;enlace&lt;/a&gt;</string>
66+
</dict>
67+
</plist>

package/demo/xcode/Localizable.xcstrings

Lines changed: 0 additions & 123 deletions
This file was deleted.

packages/cli/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"open": "^10.1.0",
4040
"ora": "^8.1.0",
4141
"p-limit": "^6.1.0",
42+
"plist": "^3.1.0",
4243
"properties-parser": "^0.6.0",
4344
"slugify": "^1.6.6",
4445
"typescript": "^5.6.3",
@@ -56,6 +57,7 @@
5657
"@types/markdown-it": "^14.1.2",
5758
"@types/node": "^20.14.10",
5859
"@types/object-hash": "^3.0.6",
60+
"@types/plist": "^3.0.5",
5961
"@types/properties-parser": "^0.3.3",
6062
"@types/xml2js": "^0.4.14",
6163
"tsup": "^8.1.0"

packages/cli/src/workers/bucket/index.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import { flatLoader } from './flat';
1010
import { yamlLoader } from './yaml';
1111
import { rootKeyLoader } from './root-key';
1212
import { markdownLoader } from './markdown';
13-
import { xcodeLoader } from './xcode';
13+
import { xcodeXcstringsLoader } from './xcode-xcstrings';
1414
import { androidLoader } from './android';
1515
import { propertiesLoader } from './properties';
16+
import { xcodeStringsLoader } from './xcode-strings';
17+
import { xcodeStringsdictLoader } from './xcode-stringsdict';
1618

1719
// Path expansion
1820
export function expandPlaceholderedGlob(pathPattern: string, sourceLocale: string): string[] {
@@ -75,27 +77,27 @@ export function createBucketLoader(params: CreateBucketLoaderParams) {
7577
switch (params.bucketType) {
7678
default:
7779
throw new Error(`Unsupported bucket type: ${params.bucketType}`);
78-
case 'json':
80+
case 'markdown':
7981
return composeLoaders<string, Record<string, string>>(
8082
textLoader(filepath),
81-
jsonLoader(),
83+
markdownLoader(),
8284
flatLoader(),
8385
);
84-
case 'yaml':
86+
case 'json':
8587
return composeLoaders<string, Record<string, string>>(
8688
textLoader(filepath),
87-
yamlLoader(),
89+
jsonLoader(),
8890
flatLoader(),
8991
);
90-
case 'markdown':
92+
case 'yaml':
9193
return composeLoaders<string, Record<string, string>>(
9294
textLoader(filepath),
93-
markdownLoader(),
95+
yamlLoader(),
9496
flatLoader(),
9597
);
96-
case 'xcode':
98+
case 'xcode-xcstrings':
9799
return composeLoaders<string, Record<string, string>>(
98-
xcodeLoader(
100+
xcodeXcstringsLoader(
99101
params.locale,
100102
composeLoaders<void, Record<string, any>>(
101103
textLoader(filepath),
@@ -104,6 +106,21 @@ export function createBucketLoader(params: CreateBucketLoaderParams) {
104106
),
105107
flatLoader(),
106108
);
109+
110+
case 'xcode-strings':
111+
return composeLoaders<string, Record<string, string>>(
112+
textLoader(filepath),
113+
xcodeStringsLoader(),
114+
flatLoader(),
115+
);
116+
117+
case 'xcode-stringsdict':
118+
return composeLoaders<string, Record<string, string>>(
119+
textLoader(filepath),
120+
xcodeStringsdictLoader(),
121+
flatLoader(),
122+
);
123+
107124
case 'yaml-root-key':
108125
return composeLoaders<string, Record<string, string>>(
109126
rootKeyLoader(

0 commit comments

Comments
 (0)