How to Localize All Your iOS Apps into 20 Languages in 5 Minutes
Introduction
In today's globalized world, the demand for mobile applications that cater to users from different countries and regions has increased significantly. To reach a wider audience, it's important for iOS application developers to make their apps accessible to users in multiple languages. Localizing an iOS app can offer many benefits:
- Reach a wider audience: By localizing your app, you can reach users who may not speak your app's default language. This can help you tap into new markets and increase your user base.
- Improve user experience: Users are more likely to use and enjoy an app that is available in their native language. Localizing your app can help you provide a better user experience, which can lead to better reviews, ratings, and retention rates. Localizing your app can give you a competitive advantage in regions where your competitors may not have localized their apps.
- Increase revenue: Localizing your app can lead to increased revenue, as users are more likely to make in-app purchases or pay for subscriptions if the app is available in their native language.
But there are also a few problems and potential issues that developers may run into. Localizing an app can be time-consuming and resource intensive, especially for apps with a large amount of content and a long list of languages. Developers must allocate sufficient time and resources to ensure effective localization.
But we wouldn't be developers if we didn't always try to automate everything. Automated localization can translate content quickly and efficiently, reduce the costs associated with manual translation, such as hiring professional translators or dedicating internal resources to the task. This is especially effective if the application is being created by a single developer.
Prepare your project
I won't go into detail about how localization of strings works in xcode project, there are already many other tutorials. I'll just highlight a few key steps:
- Create Localizable.strings file and fill it with strings you want to localize.
/* optional description */ "[key]" = "[string]"; /* Example: */ "welcome text" = "Welcome to XCodeLocalize";
- Go to the project file settings, add the desired languages. Apple recommended EFIGS (English French Italian German Spanish) + Chinese as a base.
- Create Localizable.strings files for all selected languages. You may also want to localize plist, storyboard and intentdefinition files.
Install XCodeLocalize
Unexpectedly, the ios development tool turned out to be written in python, so make sure you have python 3.9+
After that, install the tool using pip:
pip3 install xcodelocalize
Also, available installations from .whl file from github releases or via poetry from source code.
Run automatic localization
cd
to the project root folder and run
xcodelocalize [OPTIONS]
or
python3 -m xcodelocalize [OPTIONS]
Options
-
--base-language
: code of the language from which all strings will be translated. [default: 'en'] -
--override / --no-override
: a boolean value that indicates whether strings that already exist in the file will be translated. Retranslate ifoverride
, skip ifno-override
. [default: no-override] -
--format-base / --no-format-base
: sort base file strings by key. [default: no-format-base] -
--file
: Names of the strings files to be translated. Multiple files can be specified. If not specified, all files will be translated. [default: None] Example:xcodelocalize --file InfoPlist xcodelocalize --file InfoPlist --file MainStoryboard --file Localizable
-
--key
: Keys of the strings to be translated. Multiple keys can be specified. If not specified, all keys will be translated. [default: None] -
--language
: Language codes of the strings files to be translated. Multiple language codes can be specified. If not specified, all files will be translated. [default: None] -
--log-level
: One from [progress|errors|group|string]. [default: group] -
--help
: Show info
Automation
You can go to Target -> Build Phases -> New Run Script Phase
in your xcode project and paste xcodelocalize
there. It will localize necessary strings during every build and your localization files will always be up-to-date.
Conclusion
Now you know how to quickly localize your iOS applications in many other languages. Add a star to the repo if you like it.
Other articles:
- Python Architecture Essentials: Building Scalable and Clean Applications for Juniors— May 18th, 2024 · 20 min readDive into the fundamentals of scalable and clean application architecture in Python. Here, we explore essential concepts of OOP, SOLID principles, and Dependency Injection with practical examples of a real application structure.
- AI-powered Mobile App with Backend in Two Days (Tutorial)— May 5th, 2024 · 15 min readThis article delves into the nuts and bolts of creating a Proof of Concept (PoC) of a mobile app built with SwiftUI framework and a backend using FastAPI. As an extra, I'll demonstrate effective architecture patterns for SwiftUI apps, specifically MVVMP combined with SOLID principles and Dependency Injection (DI). For android, the code can be easily translated to Kotlin using Jetpack Compose Framework almost without changes.
- Dr. House — AI Diagnostician in your phone. Passing the Torch and Entrusting a Startup to Capable Hands— May 4th, 2024 · 4 min readThis article picks up where the previous one left off, [How We Built an AI Startup in a Weekend Hackathon in Germany], focusing more on the final product rather than the hackathon process itself.