iOS App Localization: Preparing and Translating Apple Strings Files with PTC

Learn how to prepare .strings files for translation and translate them with PTC (Private Translation Cloud), making iOS localization fast and easy.

In iOS app development, .strings files store all the user-facing text that appears in your app. Your app loads the right translations from these files, depending on the language the user selects.

PTC simplifies iOS localization by delivering translated .strings files in just minutes, and at a low cost. PTC understands your project’s context and provides Better Than Human Translations that need little to no editing. It also sends the translated files back to your Git repository, making it the perfect solution for anyone looking for speed, quality, and convenience.

What Does a .strings File Look Like?

A .strings file contains key-value pairs that map the text in your app to the translations users see. You’ll include any user-facing text in this file, such as:

Buttons

Text like “Login,” “Submit,” or “Settings”

Notifications

Notifications such as “Your battery is running low”

Error Messages

Alerts or notifications like “An error occurred. Please try again”

Greetings

Like “Welcome to our app!”

Here’s an example of a .strings file for an iOS app:

/* Button title */
"LOGIN_BUTTON" = "Log In";

/* Welcome message */
"WELCOME_MESSAGE" = "Welcome to our app!";

/* Error message for failed login */
"LOGIN_ERROR" = "Incorrect username or password. Please try again.";

In this example:

  • "LOGIN_BUTTON" is the key, and "Log In" is the value that appears on the button.
  • "WELCOME_MESSAGE" displays the "Welcome to our app!" greeting when the user opens the app.
  • "LOGIN_ERROR" shows the "Incorrect username or password. Please try again." error message when a login attempt fails.

Now that you know what a .strings file looks like, you’re ready to move on to the next steps: creating the file, preparing it for translation, and translating it with PTC.

Getting Your iOS App Ready for Localization

Before translating your app, you need to prepare the text properly. In this section, we’ll cover marking text for localization, managing dynamic content, and generating the .strings file so your app can easily switch between languages.

1. Mark Static Strings for Localization in Xcode

In iOS development, Xcode can gather text for translation and generate a .strings file. But first, you need to mark the static, user-facing text in your code for localization. 

To do this, go through all the user-facing text in your app and replace any hardcoded strings with NSLocalizedString. This function tells Xcode which strings should be included in the .strings file, so they can be translated later. 

For example, here’s how you mark a button label for localization:

label.text = NSLocalizedString("SUBMIT_BUTTON", comment: "Button to submit a form");

In this example:

  • SUBMIT_BUTTON" is the key that will be used in the .strings file
  • The comment provides context and explains what you use the text for

Here, it’s important that you use clear and descriptive keys. If you use vague or unclear keys in your code (like “BUTTON1″), Xcode will simply export those keys as-is into the .strings file. 

The keys act as identifiers in your code, and descriptive names help you keep track of where each string appears in the app. This makes it easier to maintain and update your .strings files over time.

2. Set Up Dynamic Content for Localization in Xcode

If your app displays dynamic content like numbers, dates, or usernames, you’ll need to set up placeholders to handle these values in the localized text. 

Similarly as for static text, you need to use NSLocalizedString in your code to mark dynamic content for translation. You’ll add the placeholder itself into the .strings file later, after you export it using Xcode.

Here’s how to mark dynamic content in your code:

let unreadMessagesCount = 5
let message = String(format: NSLocalizedString("UNREAD_MESSAGES", comment: "Message showing the number of unread messages"), unreadMessagesCount)

In the example above:

  • "UNREAD_MESSAGES" is the key that will go into the .strings file.
  • You’re passing unreadMessagesCount as the dynamic value that will display in the final message.

3. Create Your .strings File

Now that you’ve marked all the text in your app using NSLocalizedString (including dynamic content), you can generate the .strings file with Xcode’s Export for Localization feature.  This file will serve as the base for translating your app into different languages.

To generate the .strings file:

  1. Open your project in Xcode.
  2. In the menu, select EditorExport for Localization.
  3. Xcode will create a .strings file that includes all the translatable text.

Alternatively, you can manually create your .strings file. If you go with this option, you’ll need to manually identify all user-facing text in your app and create a key-value pair for each piece of text.

4. Add Placeholders for Dynamic Content in the .strings File

Now that you have your .strings file, you’ll need to do a bit of additional work to ensure dynamic content displays correctly.

For each entry where you’ve passed a dynamic value (like a number or date) in your code, add the appropriate placeholder—such as  %d for integers or %@ for strings—where the value should appear.

Here’s how to do it:

  1. Open the .strings file and locate any keys that correspond to dynamic content. For example:
"UNREAD_MESSAGES" = "Message showing the number of unread messages";
  1.  Insert the format specifier where the dynamic value should display. For example, for the "UNREAD_MESSAGES" key, add %d to show the number of unread messages, like this:
"UNREAD_MESSAGES" = "You have %d unread messages";
  1. Save the .strings file.

5. Handle Pluralization with .stringsdict Files 

If your app needs to handle pluralization (like “1 message” vs. “2 messages”), you’ll need to create .stringsdict files. These files provide the rules for plural forms in different languages, which can’t be managed with a simple .strings file.

Translating Your .strings File with PTC (For Free)

Once you have your .strings file, translating it with PTC is fast, easy, and free. PTC’s Free Resource Files Translation tool generates automatic translations for your .strings file in an instant.

Simply upload your .strings file to Free resource files translation, select the languages you need, and let PTC handle the rest. After a short wait, you can download the translations.

When you take a look at the translations, you’ll see that PTC translates the values (the text users see) but keeps the keys intact, maintaining the structure of your app. For example:

Original File ( English)

"LOGIN_BUTTON" = "Log In";
"WELCOME_MESSAGE" = "Welcome!";
"LOGIN_ERROR" = "Try again."

Translated File ( Spanish)

"LOGIN_BUTTON" = "Iniciar sesión";
"WELCOME_MESSAGE" = "¡Bienvenido!";
"LOGIN_ERROR" = "Inténtalo de nuevo.";

Adding the Translated Files to Your Project

After downloading your translations, you can add the translated .strings files to your Xcode project. 

Start by creating a separate folder for each language you translated the .strings file into. Each folder follows the format xx.lproj, where xx represents the language code. For example:

  • es.lproj for Spanish
  • fr.lproj for French

For languages with region-specific or script-specific codes, the folder names in Xcode follow a similar pattern but include the full language and region or script code. Here’s how to set them up:

  • zh-Hans.lproj for Simplified Chinese
  • pt-BR.lproj for Brazilian Portuguese
  • es-MX.lproj for Mexican Spanish

Then, place the corresponding .strings files inside each folder.

To verify everything works, change the language on your test device or simulator. Xcode should automatically load the correct .strings file based on the device’s language settings. 

Integrating iOS Localization into Your Development Flow

PTC’s Free Resource Files Translation tool gets you started by generating translated files quickly and at no cost, but a full PTC subscription offers advanced features, high-quality translations, and integration into your development workflow. This way, your app stays localized at all times.

AI-powered Translation Engine

PTC’s AI-powered translation engine starts by learning what your app is about and the category it fits into. Whether your app falls under gaming, education, finance, or another category, this context allows PTC to deliver Better Than Human Translation.

Integration with Your Code Repository

PTC sends your translated .strings file directly to your Git repository as a merge request. This saves you from having to manually upload files, making the workflow smooth and developer-friendly. 

Hands-Free Localization

With PTC’s continuous localization feature, you no longer need to manually update translations every time you add or change content. PTC automatically detects updates in your project and generates new translations.

Custom Glossary

PTC lets you build a custom glossary of terms specific to your iOS app. This keeps important terms—like product names or industry jargon—translated exactly how you want.

Get Fast, High-Quality, and Instant Translations with PTC

In this guide, you learned how to mark text for localization and prepare your .strings files for translation. You’ve also seen how you can quickly translate your app by using PTC’s Free resource files translation tool, which makes it easy to get started with accurate translations at no cost.

The free tool helps you start, but a full PTC subscription offers much more. With high-quality translations that understand your app’s needs, automatic updates to translations as your .strings file changes, and integration with your Git workflow, PTC takes care of everything.

Scroll to Top