Localizing iOS apps using string files

Save money and external dependencies.

Bruno Muniz
Dec 17, 2020 · 3 min read

In order to gain users, localizing our apps is essential since not everyone speaks the same language. Even if our app uses english strings, only a relatively thin slice of the entire global population understands it. We don’t want to lose the larger slice of the users, do we?

Photo by Vladislav Klapin on Unsplash

There are quite easy and quick ways to localize ours apps using external dependencies such as Applanga or Lokalise. I used both of them in the past, and I can vouch for them if you’re working on a enterprise level. They’re great but they’re a business and as any other: they need income to survive. If you’re an indie dev or a startup you’ll probably look for ways to not spend money unless you really have to. The good news is that there is a simple way to localize your apps without using an external service.

Its funny that under the hood, these services I mentioned also use this approach. The difference is that they have an entire web platform behind to offer translation services, android/ios support, reviews, correction, over-the-air deploy, a/b testing etc. But once the strings get downloaded, our code operates the same way.

Select the project and add the language you want to translate:

All right, now our app will look for Localizable.strings files in each language. They used to be on the project by default but in more recent xcode versions they’re not.

Create a Localizable.strings file for each language and localize:

On this step, we’ll create as many Localizable.strings file as languages we want to translate to. To localize them, first select the file then tap on ‘Localize…’ button at the Identity and Type pallete (on the right side)

This will offer you the languages that your project accepts.
en-US
pt-BR

That’s pretty much it.

Now we have different string files for each language. But how do we pipe those strings to the variables? Its simple, all we gotta do is use NSLocalizedString. To not be repetitive, let’s extend String:

And this is how it looks like on our controllers:

Voilá

Swift2Go

a place where Swift Developers share knowledge.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store