Xcode .stringsdict files
AI translation for Xcode .stringsdict files with Lingo.dev CLI
What are Xcode .stringsdict files?
Xcode .stringsdict files are Apple's format for handling plural rules and variable string formatting in iOS and macOS applications. They use a plist XML structure to define different string variations based on quantity or other variables.
For example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>welcome_message</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>Hello %#@user_count@!</string>
<key>user_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No users</string>
<key>one</key>
<string>1 user</string>
<key>other</key>
<string>%d users</string>
</dict>
</dict>
</dict>
</plist>
What is Lingo.dev CLI?
Lingo.dev CLI is a free, open-source CLI for translating apps and content with AI. It's designed to replace traditional translation management software while integrating with existing pipelines.
To learn more, see Overview.
About this guide
This guide explains how to translate Xcode .stringsdict files with Lingo.dev CLI.
You'll learn how to:
- Create a project from scratch
- Configure a translation pipeline
- Generate translations with AI
Prerequisites
To use Lingo.dev CLI, ensure that Node.js v18+ is installed:
❯ node -v
v22.17.0
Step 1. Set up a project
In your project's directory, create an i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
This file defines the behavior of the translation pipeline, including what languages to translate between and where the localizable content exists on the file system.
To learn more about the available properties, see i18n.json.
Step 2. Configure the source locale
The source locale is the original language and region that your content was written in. To configure the source locale, set the locale.source property in the i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
The source locale must be provided as a BCP 47 language tag.
For the complete list of the locale codes that Lingo.dev CLI supports, see Supported locale codes.
Step 3. Configure the target locales
The target locales are the languages and regions you want to translate your content into. To configure the target locales, set the locale.targets property in the i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
Step 4. Create the source content
If you haven't already, create one or more Xcode .stringsdict files that contain the content to be translated. These files must be located at a path that includes the source locale somewhere in the path (e.g., as a directory name like en/ or as part of the filename like messages.en.stringsdict).
Step 5. Create a bucket
-
In the
i18n.jsonfile, add a"xcode-stringsdict"object to thebucketsobject:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "xcode-stringsdict": {} } } -
In the
"xcode-stringsdict"object, define an array of one or moreincludepatterns:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "xcode-stringsdict": { "include": ["./[locale]/example.stringsdict"] } } }These patterns define which files to translate.
The patterns themselves:
- must contain
[locale]as a placeholder for the configured locale - can point to file paths (e.g.,
"[locale]/Localizable.stringsdict") - can use asterisks as wildcard placeholders (e.g.,
"[locale]/*.stringsdict")
Recursive glob patterns (e.g.,
**/*.stringsdict) are not supported. - must contain
Step 6. Configure an LLM
Lingo.dev CLI uses large language models (LLMs) to translate content with AI. To use one of these models, you need an API key from a supported provider.
To get up and running as quickly as possible, we recommend using Lingo.dev Engine — our own, hosted platform that offers 10,000 tokens of free, monthly usage:
-
Run the following command:
npx lingo.dev@latest loginThis will open your default browser and ask you to authenticte.
-
Follow the prompts.
Step 7. Generate the translations
In the directory that contains the i18n.json file, run the following command:
npx lingo.dev@latest run
This command:
- Reads the
i18n.jsonfile. - Finds the files that need to be translated.
- Extracts the translatable content from the files.
- Uses the configured LLM to translate the extracted content.
- Writes the translated content back to the file system.
The first time translations are generated, an i18n.lock file is created. This file keeps track of what content has been translated, preventing unnecessary retranslations on subsequent runs.
Example
en/example.stringsdict
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>welcome_message</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>Hello %#@user_count@!</string>
<key>user_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>No users</string>
<key>one</key>
<string>1 user</string>
<key>other</key>
<string>%d users</string>
</dict>
</dict>
</dict>
</plist>
es/example.stringsdict
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>welcome_message</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>¡Hola %#@user_count@!</string>
<key>user_count</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>zero</key>
<string>Sin usuarios</string>
<key>one</key>
<string>1 usuario</string>
<key>other</key>
<string>%d usuarios</string>
</dict>
</dict>
</dict>
</plist>
i18n.json
{
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {
"xcode-stringsdict": {
"include": ["./[locale]/example.stringsdict"]
}
},
"$schema": "https://lingo.dev/schema/i18n.json"
}
i18n.lock
version: 1
checksums:
a96f640d0f744d993247e36ea1b33052:
welcome_message/NSStringLocalizedFormatKey: f142738692c027d95dce521e7cb29c82
welcome_message/user_count/NSStringFormatSpecTypeKey: 8cc03ef30ad5b2d8e27f3612627d932e
welcome_message/user_count/NSStringFormatValueTypeKey: fe9efa39a6fd9f10358f43f00e0ab82b
welcome_message/user_count/zero: 3d4643c483a49c2f61e17aaa8620e71e
welcome_message/user_count/one: 3b547431ab12f0fba84307e6a81109d8
welcome_message/user_count/other: cb01ae522c991a2ad651b4049339c48a
notification_count/NSStringLocalizedFormatKey: e01fd796051132b678d7574a11e9a944
notification_count/count/NSStringFormatSpecTypeKey: 8cc03ef30ad5b2d8e27f3612627d932e
notification_count/count/NSStringFormatValueTypeKey: fe9efa39a6fd9f10358f43f00e0ab82b
notification_count/count/zero: ac0137deebf6e2b972c6c714dd8658ee
notification_count/count/other: 9b350a78e1c499b9ab69eb330162c8ee