how to translate entire iOS app into different language
Categories:
Localizing Your iOS App: A Comprehensive Guide to Multi-Language Support

Learn how to translate your entire iOS application into multiple languages, providing a seamless experience for a global audience using Xcode's localization features.
In today's globalized world, offering your iOS application in multiple languages is crucial for reaching a wider audience and enhancing user experience. Localization involves adapting your app's text, images, and other resources to suit different linguistic and cultural contexts. This guide will walk you through the process of localizing an entire iOS app using Xcode's built-in tools, covering everything from setting up your project for localization to managing translated strings and testing your localized app.
1. Setting Up Your Project for Localization
The first step in localizing your iOS app is to enable localization for your project and add the languages you intend to support. Xcode provides a straightforward interface for this, allowing you to manage all your localization settings in one place.
1. Enable Base Localization
Open your Xcode project, select the project in the Project Navigator, then navigate to the 'Info' tab. Under 'Localizations', check the 'Use Base Internationalization' checkbox. This creates a Base.lproj
folder for your default language resources.
2. Add New Languages
Still in the 'Localizations' section, click the '+' button to add new languages. Xcode will prompt you to select which resources (e.g., Main.storyboard
, LaunchScreen.storyboard
, InfoPlist.strings
) you want to localize for the newly added language. Select all relevant files.
2. Localizing User Interface Elements (Storyboards/NIBs)
For UI elements defined in Storyboards or NIBs, Xcode generates .strings
files that contain key-value pairs for each localizable string. You'll translate these files to localize your UI.
1. Generate Localizable Strings Files
After adding a new language, Xcode automatically creates a .strings
file for each localized storyboard/NIB (e.g., Main.strings (English)
, Main.strings (French)
). These files contain object IDs and their corresponding text properties.
2. Translate Storyboard/NIB Strings
Open the .strings
file for the target language (e.g., Main.strings (French)
). For each entry, replace the English string with its translation. The format is "Object ID.property" = "Translated String";
.
/* Class = "UILabel"; text = "Welcome"; ObjectID = "aBc-XyZ-123"; */
"aBc-XyZ-123.text" = "Bienvenue";
/* Class = "UIButton"; normalTitle = "Login"; ObjectID = "dEf-GhI-456"; */
"dEf-GhI-456.normalTitle" = "Connexion";
Example of a Main.strings
file for French localization.
3. Localizing Programmatic Strings and Info.plist
Strings used in your code and entries in your Info.plist
file also need to be localized. This is typically done using Localizable.strings
files and InfoPlist.strings
files, respectively.
1. Create Localizable.strings File
Create a new file in Xcode (File > New > File...), select 'Strings File' under 'Resource'. Name it Localizable.strings
. Select this file in the Project Navigator, open the File Inspector, and click 'Localize...'. Choose your base language, then add other languages by checking them in the File Inspector.
2. Add Key-Value Pairs
In each Localizable.strings
file (e.g., Localizable.strings (English)
, Localizable.strings (French)
), add key-value pairs for your programmatic strings. The format is "KEY" = "Translated String";
.
3. Use NSLocalizedString in Code
In your Swift or Objective-C code, use NSLocalizedString("KEY", comment: "Optional comment for translator")
to retrieve the localized string for the current device language.
4. Localize Info.plist Entries
Create an InfoPlist.strings
file for each language (similar to Localizable.strings
). In these files, you can localize values like CFBundleDisplayName
(app name) or NSCameraUsageDescription
(privacy descriptions).
let welcomeMessage = NSLocalizedString("WELCOME_MESSAGE", comment: "Greeting message for the user")
myLabel.text = welcomeMessage
// In Localizable.strings (English):
// "WELCOME_MESSAGE" = "Hello, World!";
// In Localizable.strings (French):
// "WELCOME_MESSAGE" = "Bonjour le monde!";
Using NSLocalizedString
for programmatic string localization.
/* Localized versions of Info.plist keys */
CFBundleDisplayName = "My Awesome App";
NSCameraUsageDescription = "This app needs camera access to take photos.";
Example InfoPlist.strings
for English.
Localizable.strings
files are unique and consistent across all languages. Mismatched keys will result in untranslated strings.4. Localizing Images and Other Resources
Beyond text, you might need to localize images, sounds, or other assets that vary by culture or language.
1. Localize Image Assets
Select an image asset in your Assets.xcassets. In the Attributes Inspector, click 'Localize...'. Choose the languages you want to localize it for. Xcode will then allow you to provide different image files for each language directly within the asset catalog.
2. Localize Other Files
For other file types (e.g., PDFs, audio files), select the file in the Project Navigator, open the File Inspector, and click 'Localize...'. Xcode will create language-specific folders (en.lproj
, fr.lproj
) where you can place the localized versions of these files.
flowchart TD A[Start Localization Process] --> B{Enable Base Internationalization} B --> C{Add Target Languages} C --> D{Localize Storyboards/NIBs} D --> E{Localize Programmatic Strings} E --> F{Localize Info.plist} F --> G{Localize Images/Assets} G --> H{Test Localized App} H --> I[End Localization Process]
Overall workflow for localizing an iOS application.
5. Testing Your Localized App
Thorough testing is essential to ensure that all strings are translated correctly, layouts adapt to different text lengths, and localized assets are displayed properly.
1. Change Scheme Language
In Xcode, go to Product > Scheme > Edit Scheme... Select 'Run' from the left panel, then the 'Options' tab. Under 'App Language', choose the language you want to test. This will launch your app in the selected language on the simulator or device.
2. Test on Device Language
Alternatively, you can change the language of your iOS device or simulator via Settings > General > Language & Region to test how your app behaves with the system's preferred language.
3. Check UI Layouts
Pay close attention to UI elements. Some languages (e.g., German) have longer words, which can cause text truncation or layout issues. Adjust constraints or font sizes as needed.