iOS Localization: How to Translate Apple Stringsdict Files with PTC

PTC (Private Translation Cloud) simplifies translating Apple .stringsdict files, helping your iOS and macOS apps support multiple languages.

To fully localize your app, you’ll need to work with both .strings and .stringsdict files. While .strings files handle simple key-value pairs, .stringsdict files manage more complex scenarios, like plural forms and dynamic text.

This guide explains how to prepare and translate .stringsdict files using PTC.

Preparing Your .stringsdict File for Translation

Before translating, it’s important to understand how .stringsdict files work, create them, and set them up correctly.

1. Understand the Structure of a .stringsdict File

A .stringsdict file is an XML-based file that uses dictionaries to define how text changes based on rules. These rules allow your app to display text dynamically, such as singular or plural forms depending on a number.

Here’s an example of how a .stringsdict file manages pluralization:

xml
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
  <key>unread_messages</key>
  <dict>
    <key>NSStringLocalizedFormatKey</key>
    <string>%#@unread@</string>
    <key>unread</key>
    <dict>
      <key>NSStringFormatSpecTypeKey</key>
      <string>NSStringPluralRuleType</string>
      <key>NSStringFormatValueTypeKey</key>
      <string>d</string>
      <key>one</key>
      <string>You have 1 unread message</string>
      <key>other</key>
      <string>You have %d unread messages</string>
    </dict>
  </dict>
</dict>
</plist>

How it works:

  • Key (unread_messages): Refers to the text you want to display.
  • Placeholders (%#@unread@): Insert dynamic values.
  • Pluralization Rules: Define how text changes for singular (one) and plural (other) forms.

After you translate the .stringsdict file, you’ll see that the keys (e.g., unread_messages) remain in the source language. Only see the values (You have 1 unread message ) get translated. This way, your app will continue to reference the correct keys in your code while the content changes to match the selected language.

2. Create Your .stringsdict File

Create the .stringsdict file in Xcode and name it appropriately (e.g., Localizable.stringsdict). Add it to the correct language folder, such as en.lproj for English . If the folders for your project’s languages don’t exist, you can create them manually, or Xcode will generate them when you localize the .stringsdict file.

3. Add Plural and Dynamic Text

Add all text that depends on numbers or variables to the .stringsdict file in your source language. PTC will handle translations for other languages.

Examples include:

Plural forms

Any text that changes based on singular and plural form

Example string (part of a broader .stringsdict file):

You have %d new files.

What the user will see:

1 file: You have 1 new file
3 files: You have 3 new files
Dynamic content

Any content that changes based on data, user behavior and preferences

Example string(part of a broader .stringsdict file):

Welcome, %@!

What the user will see:

For the user John: Welcome, John!
For the user Emma: Welcome, Emma!

For all plural and dynamic content, use placeholders in your .stringsdict file. These placeholders represent values that your app will insert into the text at runtime, such as a user’s name or the number of messages.

Common placeholders include:

  • %@: For strings, such as names
  • %d: For integers, such as numbers of items
  • %f: For floating-point numbers, such as percentages

For a complete list of suggested placeholders, see Apple’s official format specifiers documentation.

4. Reference the .stringsdict File in Your Code

Use NSLocalizedString in your code to access text from the .stringsdict file. Combine it with format specifiers for dynamic content or plural forms.

Example: Plural Forms

swift
let unreadMessagesCount = 5
let message = String(format: NSLocalizedString("unread_messages", comment: ""), unreadMessagesCount)

In this example:

  • In your .stringsdict file, the key unread_messages handles the pluralization rules
  • If unreadMessagesCount equals 1, the app displays: You have 1 unread message
  • If unreadMessagesCount equals 5, the app displays: You have 5 unread messages

Example: Dynamic Content

swift
let userName = "John"
let welcomeMessage = String(format: NSLocalizedString("welcome_user", comment: ""), userName)

In this example:

  • In your .stringsdict file, the key welcome_user handles dynamic content.
  • The %@ placeholder gets replaced by the user’s name. For example: Welcome, John!

5. Test Your .stringsdict File

Before translating, test your .stringsdict file in the source language. Use different inputs to confirm pluralization and dynamic text display correctly. Check edge cases like zero values or unusual inputs to ensure the rules work as expected.

Translating .stringsdict Files with PTC

Once you have your .stringsdict file set up and tested, PTC simplifies the translation process:

Connect PTC with Your Repository

During project setup, PTC connects to your repository and detects all the resource files in it—including .strings and .stringsdict files.

Translate with AI

PTC uses AI to understand the nuances of your app or software, allowing it to deliver Better Than Human Translations.

Original File ( English)

Translated File ( Spanish)

Translations Delivered to Your Code Repository

Once PTC finishes translating, it delivers the translations to your code repository as a merge request. You can review and merge the changes into your project when ready.

Continuous Localization

PTC monitors your repository for changes and updates translations whenever you modify your source files.

Ready to Translate Your .stringsdict File?

In this guide, you’ve covered the essentials of working with Apple’s .stringsdict files, from understanding their structure to preparing them for translation.

You’ve also seen how easy it is to translate your resource files. With AI-powered translations tailored to your project, Git integration, and automated updates, PTC simplifies your entire localization process and saves you time and resources.

Start translating .stringsdict files today

Start your 30-day trial and get AI-powered translations for your StringsDict files.

Scroll to Top