Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"eslint": "eslint --max-warnings 0",
"format": "eslint --fix",
"run-dev": "tsx ./src/cli.ts",
"schema": "openapi-typescript http://localhost:22222/v3/api-docs/All%20Internal%20-%20for%20Tolgee%20Web%20application --output src/client/internal/schema.generated.ts",
"schema": "openapi-typescript http://localhost:8080/v3/api-docs/All%20Internal%20-%20for%20Tolgee%20Web%20application --output src/client/internal/schema.generated.ts",
"release": "semantic-release",
"config:type": "tsx scripts/configType.ts"
},
Expand Down
1 change: 1 addition & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
"PO_PYTHON",
"APPLE_STRINGS",
"APPLE_XLIFF",
"APPLE_XCSTRINGS",
"PROPERTIES_ICU",
"PROPERTIES_JAVA",
"ANDROID_XML",
Expand Down
14 changes: 8 additions & 6 deletions src/client/internal/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4639,7 +4639,7 @@ export interface components {
* @description Format to export to
* @enum {string}
*/
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";
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";
/** Format: int64 */
id: number;
/**
Expand Down Expand Up @@ -4723,7 +4723,7 @@ export interface components {
* @description Format to export to
* @enum {string}
*/
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";
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";
/**
* @description Languages to be contained in export.
*
Expand Down Expand Up @@ -4973,7 +4973,7 @@ export interface components {
defaultFileStructureTemplate: string;
extension: string;
/** @enum {string} */
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";
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";
mediaType: string;
};
ExportParams: {
Expand Down Expand Up @@ -5013,7 +5013,7 @@ export interface components {
* @description Format to export to
* @enum {string}
*/
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";
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";
/**
* @description Languages to be contained in export.
*
Expand Down Expand Up @@ -5091,7 +5091,7 @@ export interface components {
* It is recommended to provide these values to prevent any issues with format detection.
* @enum {string}
*/
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";
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";
/** @description The existing language tag in the Tolgee platform to which the imported language should be mapped.
*
* When null, Tolgee will try to guess the language from the file contents or file name. */
Expand Down Expand Up @@ -6595,6 +6595,8 @@ export interface components {
id: number;
keyReferences: components["schemas"]["KeyInScreenshotModel"][];
location?: string;
middleSized?: string;
middleSizedUrl?: string;
/** @description Thumbnail file name, which may be downloaded from the screenshot path.
*
* When images are secured. Encrypted timestamp is appended to the filename.
Expand Down Expand Up @@ -13928,7 +13930,7 @@ export interface operations {
*/
languages?: string[];
/** @description Format to export to */
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";
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";
/** @description Delimiter to structure file content.
*
* e.g. For key "home.header.title" would result in {"home": {"header": "title": {"Hello"}}} structure.
Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const FORMAT_OPT = new Option(
'PO_PYTHON',
'APPLE_STRINGS',
'APPLE_XLIFF',
'APPLE_XCSTRINGS',
'PROPERTIES_ICU',
'PROPERTIES_JAVA',
'ANDROID_XML',
Expand Down
1 change: 1 addition & 0 deletions src/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export type Format =
| "PO_PYTHON"
| "APPLE_STRINGS"
| "APPLE_XLIFF"
| "APPLE_XCSTRINGS"
| "PROPERTIES_ICU"
| "PROPERTIES_JAVA"
| "ANDROID_XML"
Expand Down
2 changes: 2 additions & 0 deletions src/utils/mapExportFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const mapExportFormat = (format: Schema['format']): FormatResult => {
};
case 'APPLE_XLIFF':
return { format: 'APPLE_XLIFF', messageFormat: 'APPLE_SPRINTF' };
case 'APPLE_XCSTRINGS':
return { format: 'APPLE_XCSTRINGS', messageFormat: 'APPLE_SPRINTF' };
case 'COMPOSE_XML':
return { format: 'COMPOSE_XML', messageFormat: 'JAVA_STRING_FORMAT' };
case 'FLUTTER_ARB':
Expand Down
2 changes: 2 additions & 0 deletions src/utils/mapImportFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const mapImportFormat = (
extension: string
): FormatResult => {
switch (format) {
case 'APPLE_XCSTRINGS':
return 'XCSTRINGS';
case 'APPLE_STRINGS': {
// apple separates translations to two separate files
// we keep it under one format for the cli
Expand Down
12 changes: 12 additions & 0 deletions test/__fixtures__/differentFormatsProject/apple-xcstrings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "../../../schema.json",
"format": "APPLE_XCSTRINGS",
"push": {
"files": [
{
"path": "./apple-xcstrings/Localizable.xcstrings",
"language": "en"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"sourceLanguage" : "cs",
"strings" : {
"dog_count" : {
"localizations" : {
"cs" : {
"variations" : {
"plural" : {
"few" : {
"stringUnit" : {
"state" : "translated",
"value" : "Já mám %lli psi."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
"value" : "Já mám jednoho psa."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "Já mám %lli psů."
}
}
}
}
},
"en" : {
"variations" : {
"plural" : {
"other" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "I have %%lli dogs."
}
}
}
}
}
}
},
"my_mom" : {
"extractionState" : "manual",
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "Tohle je moje máma!"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "This is my mom!"
}
}
}
},
"test_key" : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
"value" : "O muj boze!"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Oh my god!"
}
}
}
}
},
"version" : "1.0"
}
9 changes: 9 additions & 0 deletions test/e2e/formats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'OVERRIDE',
]);

expect(outPush.code).toBe(0);

Check failure on line 52 in test/e2e/formats.test.ts

View workflow job for this annotation

GitHub Actions / E2E Tests (ubuntu-latest, 18)

test/e2e/formats.test.ts > push and pull with different formats > works with Apple xcstrings (StringCatalog) format

AssertionError: expected 1 to be +0 // Object.is equality - Expected + Received - 0 + 1 ❯ testWithConfig test/e2e/formats.test.ts:52:24 ❯ test/e2e/formats.test.ts:145:5

Check failure on line 52 in test/e2e/formats.test.ts

View workflow job for this annotation

GitHub Actions / E2E Tests (ubuntu-latest, 20)

test/e2e/formats.test.ts > push and pull with different formats > works with Apple xcstrings (StringCatalog) format

AssertionError: expected 1 to be +0 // Object.is equality - Expected + Received - 0 + 1 ❯ testWithConfig test/e2e/formats.test.ts:52:24 ❯ test/e2e/formats.test.ts:145:5

Check failure on line 52 in test/e2e/formats.test.ts

View workflow job for this annotation

GitHub Actions / E2E Tests (ubuntu-latest, 22)

test/e2e/formats.test.ts > push and pull with different formats > works with Apple xcstrings (StringCatalog) format

AssertionError: expected 1 to be +0 // Object.is equality - Expected + Received - 0 + 1 ❯ testWithConfig test/e2e/formats.test.ts:52:24 ❯ test/e2e/formats.test.ts:145:5

const keys = await client.GET('/v2/projects/{projectId}/translations', {
params: { path: { projectId: client.getProjectId() } },
Expand Down Expand Up @@ -141,6 +141,15 @@
});
});

it('works with Apple xcstrings (StringCatalog) format', async () => {
await testWithConfig({
config: 'apple-xcstrings',
inPlatform: 'This is my mom!',
fileLocation: 'Localizable.strings',
inFile: 'I have %%lli dogs.',
});
});

it('works with android-xml icu format', async () => {
await testWithConfig({
config: 'android-xml',
Expand Down
Loading