Skip to content

Commit f5415c0

Browse files
committed
feat: Add Apple xc strings
1 parent de1a28d commit f5415c0

File tree

10 files changed

+116
-7
lines changed

10 files changed

+116
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"eslint": "eslint --max-warnings 0",
2424
"format": "eslint --fix",
2525
"run-dev": "tsx ./src/cli.ts",
26-
"schema": "openapi-typescript http://localhost:22222/v3/api-docs/All%20Internal%20-%20for%20Tolgee%20Web%20application --output src/client/internal/schema.generated.ts",
26+
"schema": "openapi-typescript http://localhost:8080/v3/api-docs/All%20Internal%20-%20for%20Tolgee%20Web%20application --output src/client/internal/schema.generated.ts",
2727
"release": "semantic-release",
2828
"config:type": "tsx scripts/configType.ts"
2929
},

schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
"PO_PYTHON",
252252
"APPLE_STRINGS",
253253
"APPLE_XLIFF",
254+
"APPLE_XCSTRINGS",
254255
"PROPERTIES_ICU",
255256
"PROPERTIES_JAVA",
256257
"ANDROID_XML",

src/client/internal/schema.generated.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4639,7 +4639,7 @@ export interface components {
46394639
* @description Format to export to
46404640
* @enum {string}
46414641
*/
4642-
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
4642+
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "APPLE_XCSTRINGS" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
46434643
/** Format: int64 */
46444644
id: number;
46454645
/**
@@ -4723,7 +4723,7 @@ export interface components {
47234723
* @description Format to export to
47244724
* @enum {string}
47254725
*/
4726-
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
4726+
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "APPLE_XCSTRINGS" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
47274727
/**
47284728
* @description Languages to be contained in export.
47294729
*
@@ -4973,7 +4973,7 @@ export interface components {
49734973
defaultFileStructureTemplate: string;
49744974
extension: string;
49754975
/** @enum {string} */
4976-
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
4976+
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "APPLE_XCSTRINGS" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
49774977
mediaType: string;
49784978
};
49794979
ExportParams: {
@@ -5013,7 +5013,7 @@ export interface components {
50135013
* @description Format to export to
50145014
* @enum {string}
50155015
*/
5016-
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
5016+
format: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "APPLE_XCSTRINGS" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
50175017
/**
50185018
* @description Languages to be contained in export.
50195019
*
@@ -5091,7 +5091,7 @@ export interface components {
50915091
* It is recommended to provide these values to prevent any issues with format detection.
50925092
* @enum {string}
50935093
*/
5094-
format?: "CSV_ICU" | "CSV_JAVA" | "CSV_PHP" | "CSV_RUBY" | "JSON_I18NEXT" | "JSON_ICU" | "JSON_JAVA" | "JSON_PHP" | "JSON_RUBY" | "JSON_C" | "PO_PHP" | "PO_C" | "PO_JAVA" | "PO_ICU" | "PO_RUBY" | "PO_PYTHON" | "STRINGS" | "STRINGSDICT" | "APPLE_XLIFF" | "PROPERTIES_ICU" | "PROPERTIES_JAVA" | "PROPERTIES_UNKNOWN" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "YAML_RUBY" | "YAML_JAVA" | "YAML_ICU" | "YAML_PHP" | "YAML_UNKNOWN" | "XLIFF_ICU" | "XLIFF_JAVA" | "XLIFF_PHP" | "XLIFF_RUBY" | "RESX_ICU" | "XLSX_ICU" | "XLSX_JAVA" | "XLSX_PHP" | "XLSX_RUBY";
5094+
format?: "CSV_ICU" | "CSV_JAVA" | "CSV_PHP" | "CSV_RUBY" | "JSON_I18NEXT" | "JSON_ICU" | "JSON_JAVA" | "JSON_PHP" | "JSON_RUBY" | "JSON_C" | "PO_PHP" | "PO_C" | "PO_JAVA" | "PO_ICU" | "PO_RUBY" | "PO_PYTHON" | "STRINGS" | "STRINGSDICT" | "APPLE_XLIFF" | "XCSTRINGS" | "PROPERTIES_ICU" | "PROPERTIES_JAVA" | "PROPERTIES_UNKNOWN" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "YAML_RUBY" | "YAML_JAVA" | "YAML_ICU" | "YAML_PHP" | "YAML_UNKNOWN" | "XLIFF_ICU" | "XLIFF_JAVA" | "XLIFF_PHP" | "XLIFF_RUBY" | "RESX_ICU" | "XLSX_ICU" | "XLSX_JAVA" | "XLSX_PHP" | "XLSX_RUBY";
50955095
/** @description The existing language tag in the Tolgee platform to which the imported language should be mapped.
50965096
*
50975097
* When null, Tolgee will try to guess the language from the file contents or file name. */
@@ -6595,6 +6595,8 @@ export interface components {
65956595
id: number;
65966596
keyReferences: components["schemas"]["KeyInScreenshotModel"][];
65976597
location?: string;
6598+
middleSized?: string;
6599+
middleSizedUrl?: string;
65986600
/** @description Thumbnail file name, which may be downloaded from the screenshot path.
65996601
*
66006602
* When images are secured. Encrypted timestamp is appended to the filename.
@@ -13928,7 +13930,7 @@ export interface operations {
1392813930
*/
1392913931
languages?: string[];
1393013932
/** @description Format to export to */
13931-
format?: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
13933+
format?: "JSON" | "JSON_TOLGEE" | "XLIFF" | "PO" | "APPLE_STRINGS_STRINGSDICT" | "APPLE_XLIFF" | "APPLE_XCSTRINGS" | "ANDROID_XML" | "COMPOSE_XML" | "FLUTTER_ARB" | "PROPERTIES" | "YAML_RUBY" | "YAML" | "JSON_I18NEXT" | "CSV" | "RESX_ICU" | "XLSX";
1393213934
/** @description Delimiter to structure file content.
1393313935
*
1393413936
* e.g. For key "home.header.title" would result in {"home": {"header": "title": {"Hello"}}} structure.

src/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const FORMAT_OPT = new Option(
8484
'PO_PYTHON',
8585
'APPLE_STRINGS',
8686
'APPLE_XLIFF',
87+
'APPLE_XCSTRINGS',
8788
'PROPERTIES_ICU',
8889
'PROPERTIES_JAVA',
8990
'ANDROID_XML',

src/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type Format =
2424
| "PO_PYTHON"
2525
| "APPLE_STRINGS"
2626
| "APPLE_XLIFF"
27+
| "APPLE_XCSTRINGS"
2728
| "PROPERTIES_ICU"
2829
| "PROPERTIES_JAVA"
2930
| "ANDROID_XML"

src/utils/mapExportFormat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const mapExportFormat = (format: Schema['format']): FormatResult => {
1717
};
1818
case 'APPLE_XLIFF':
1919
return { format: 'APPLE_XLIFF', messageFormat: 'APPLE_SPRINTF' };
20+
case 'APPLE_XCSTRINGS':
21+
return { format: 'APPLE_XCSTRINGS', messageFormat: 'APPLE_SPRINTF' };
2022
case 'COMPOSE_XML':
2123
return { format: 'COMPOSE_XML', messageFormat: 'JAVA_STRING_FORMAT' };
2224
case 'FLUTTER_ARB':

src/utils/mapImportFormat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const mapImportFormat = (
88
extension: string
99
): FormatResult => {
1010
switch (format) {
11+
case 'APPLE_XCSTRINGS':
12+
return 'XCSTRINGS';
1113
case 'APPLE_STRINGS': {
1214
// apple separates translations to two separate files
1315
// we keep it under one format for the cli
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "../../../schema.json",
3+
"format": "APPLE_XCSTRINGS",
4+
"push": {
5+
"files": [
6+
{
7+
"path": "./apple-xcstrings/Localizable.xcstrings",
8+
"language": "en"
9+
}
10+
]
11+
}
12+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"sourceLanguage" : "cs",
3+
"strings" : {
4+
"dog_count" : {
5+
"localizations" : {
6+
"cs" : {
7+
"variations" : {
8+
"plural" : {
9+
"few" : {
10+
"stringUnit" : {
11+
"state" : "translated",
12+
"value" : "Já mám %lli psi."
13+
}
14+
},
15+
"one" : {
16+
"stringUnit" : {
17+
"state" : "translated",
18+
"value" : "Já mám jednoho psa."
19+
}
20+
},
21+
"other" : {
22+
"stringUnit" : {
23+
"state" : "translated",
24+
"value" : "Já mám %lli psů."
25+
}
26+
}
27+
}
28+
}
29+
},
30+
"en" : {
31+
"variations" : {
32+
"plural" : {
33+
"other" : {
34+
"stringUnit" : {
35+
"state" : "needs_review",
36+
"value" : "I have %%lli dogs."
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
},
44+
"my_mom" : {
45+
"extractionState" : "manual",
46+
"localizations" : {
47+
"cs" : {
48+
"stringUnit" : {
49+
"state" : "translated",
50+
"value" : "Tohle je moje máma!"
51+
}
52+
},
53+
"en" : {
54+
"stringUnit" : {
55+
"state" : "translated",
56+
"value" : "This is my mom!"
57+
}
58+
}
59+
}
60+
},
61+
"test_key" : {
62+
"localizations" : {
63+
"cs" : {
64+
"stringUnit" : {
65+
"state" : "translated",
66+
"value" : "O muj boze!"
67+
}
68+
},
69+
"en" : {
70+
"stringUnit" : {
71+
"state" : "translated",
72+
"value" : "Oh my god!"
73+
}
74+
}
75+
}
76+
}
77+
},
78+
"version" : "1.0"
79+
}

test/e2e/formats.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ describe('push and pull with different formats', () => {
141141
});
142142
});
143143

144+
it('works with Apple xcstrings (StringCatalog) format', async () => {
145+
await testWithConfig({
146+
config: 'apple-xcstrings',
147+
inPlatform: 'This is my mom!',
148+
fileLocation: 'Localizable.strings',
149+
inFile: 'I have %%lli dogs.',
150+
});
151+
});
152+
144153
it('works with android-xml icu format', async () => {
145154
await testWithConfig({
146155
config: 'android-xml',

0 commit comments

Comments
 (0)