|
| 1 | +--- |
| 2 | +id: apple_xcstrings |
| 3 | +title: Apple String Catalog (.xcstrings) |
| 4 | +sidebar_label: Apple String Catalog |
| 5 | +--- |
| 6 | + |
| 7 | +Apple String Catalog is the latest Apple approach to localization for Apple platforms. |
| 8 | +We recommend using it in favor of XLIFF since this format gives you |
| 9 | +better control over the strings and their translations. |
| 10 | + |
| 11 | +Tolgee supports simple values as well as plural values. |
| 12 | + |
| 13 | +Example of a Stringsdict file: |
| 14 | +```json |
| 15 | +{ |
| 16 | + "sourceLanguage": "en", |
| 17 | + "version": "1.0", |
| 18 | + "strings": { |
| 19 | + "dog_count": { |
| 20 | + "localizations": { |
| 21 | + "en": { |
| 22 | + "variations": { |
| 23 | + "plural": { |
| 24 | + "other": { |
| 25 | + "stringUnit": { |
| 26 | + "state": "translated", |
| 27 | + "value": "I have %lld dogs." |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + }, |
| 33 | + "cs": { |
| 34 | + "variations": { |
| 35 | + "plural": { |
| 36 | + "one": { |
| 37 | + "stringUnit": { |
| 38 | + "state": "translated", |
| 39 | + "value": "Já mám jednoho psa." |
| 40 | + } |
| 41 | + }, |
| 42 | + "few": { |
| 43 | + "stringUnit": { |
| 44 | + "state": "translated", |
| 45 | + "value": "Já mám %lld psi." |
| 46 | + } |
| 47 | + }, |
| 48 | + "other": { |
| 49 | + "stringUnit": { |
| 50 | + "state": "translated", |
| 51 | + "value": "Já mám %lld psů." |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + }, |
| 59 | + "hello": { |
| 60 | + "en": { |
| 61 | + "stringUnit": { |
| 62 | + "state": "translated", |
| 63 | + "value": "Hello!" |
| 64 | + } |
| 65 | + }, |
| 66 | + "localizations": { |
| 67 | + "cs": { |
| 68 | + "stringUnit": { |
| 69 | + "state": "translated", |
| 70 | + "value": "Ahoj!" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +We recommend using the semantic keys format as in the examples above. That enables you to change the base values without |
| 80 | +modifying the key and doesn't suggest keeping the keys in sync with the base language translation. |
| 81 | + |
| 82 | +import ApplePlaceholders from './components/_apple_placeholders.mdx'; |
| 83 | + |
| 84 | +<ApplePlaceholders /> |
| 85 | + |
| 86 | +import Importing from './components/_general_importing.mdx'; |
| 87 | + |
| 88 | +<Importing /> |
| 89 | + |
| 90 | +# Using with the CLI |
| 91 | + |
| 92 | +Apple String Catalog (.xcstrings) format differs slightly from other formats because it contains all the languages in a single file. |
| 93 | + |
| 94 | +You will probably want to push only the base language (usually English) since translating other languages will happen in the Tolgee Platform. That's why we set the `push.languages` to `["en"]`, so Tolgee will ignore all other languages included in the `.xcstrings`. |
| 95 | + |
| 96 | +For pulling, you usually want to use all the languages from the Tolgee platform, so we are keeping the default for the `pull` option. |
| 97 | + |
| 98 | +```json |
| 99 | +{ |
| 100 | + "$schema": "https://docs.tolgee.io/cli-schema.json", |
| 101 | + "projectId": 123, // project id in tolgee platform |
| 102 | + "format": "APPLE_XCSTRINGS", |
| 103 | + "push": { |
| 104 | + "filesTemplate": "./i18n/Localizable.xcstrings", |
| 105 | + "languages": ["en"] // which languages should be pushed by default |
| 106 | + }, |
| 107 | + "pull": { |
| 108 | + "path": "./i18n" |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +> Read [more about CLI](/tolgee-cli) |
0 commit comments