Localize Swift Tutorial
Creating an App for multiple languages? Let us make this easy!
It is really important to enable your App for multiple languages. By using Localize you can ensure that your App will maximize it’s
- Some basic knowledge of creating iOS Apps
Language Localization: The process of adapting a product into multiple languages for a country or region
Did you know
Localizing your App can supercharge your implementation. The global population consists of just 6% native English speakers.
This means that you can not only be available on multiple App Stores, but your App can be suitable for those markets too, making your App ready for the 94% of the population increasing your customer satisfaction (reviews!) and implement localization early in the development of your App to save the money that it would take to change your App to localize the content after going to production.
Set up a new Xcode single view project
Set up a single view project through Xcode
Installing through Carthage
The easiest way to install Cathage is through Brew. (alternative installation methods are avaliable through https://github.com/Carthage/Carthage#installing-carthage)
But for brew we simply need to update brew
$ brew update
$ brew install carthage
Once installed, at any time you can check the version of carthage
We will use vim to create our cartfile. It is possible to use your text editor of choice here, but the tutorial will use vim.
Make sure you run this from the folder with your project.
$ vim Cartfile
and then add the following
We can clone dependencies with the following command, and it operates on the clones as specified in the Cartfile.
$ carthage update — — platform iOS
Drag in the Localize_swift.framework from the Build>iOS folder to the Linked Frameworks and Libraries (available when the target is selected, and the general tab is selected).
Add the following in Build Phases, Add + on the top-left hand corner of the window and a new run script phase and add the following:
and then under input files add an entry for the framework:
Localize is then ready to run!
Installing through CocoaPods
and add the following to the Podfile
pod ‘Localise-Swift’, ‘~> 2.0’
followed by a pod install
At the beginning of any class where you want to localize the content you need to import Localize_swift, using the following
You can add localization files through Project>Info>Localizations
Towards the bottom of the screen the Use Base Internationalization tick box is checked. This is what we want so no action required here!
You may be aware that your project is already organized around a Base.lproj folder
This is the initial Base language, and is only used when a language is not supported in localizable.strings.
We need to press the friendly-looking + button to add extra localizations to our project. For example here we will choose Chinese (simplified)
Which of course can be selected from the list
Pressing the finish button generates new files under the target language:
Within our file structure we have a reassuring new folder. Because I picked Chinese(simplified) I have a new folder; zh-Hans.lproj
Xcode has given us files as LaunchScreen.strings and Main.strings
Which brings us to…we don’t have a localizable.strings file yet, do we?
to make it trivial to find, I’ve looked for all files beginning with “str”
Inevitably I’ve called the file Localizable.strings
This creates the file, but only for the Base language. To remedy this, we can press the localize… button in the File Inspector.
So we can then select our added language(s) and click the Localize button
We need to have both files (in my case English and Chinese(Simplified) by selecting all the languages in localization.
The only issue is that each localization needs to be ended with a semi-colon.
So my Localizable.strings(Chinese(Simplified)) looks something like:
And my English version can look like:
and we can also see the files around our Localizable.string file:
The Localize Swift is available at the following repository:
Swift friendly localization and i18n with in-app language switching - marmelroy/Localize-Swift
Want to get in contact? Use Twitter: