Localizing iOS apps using string files

Save money and external dependencies.

Bruno Muniz
Swift2Go

--

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.

Internationalization is the design and development of a product, application or document content that enables easy localization for target audiences that vary in culture, region, or language.

Localization refers to the adaptation of a product, application or document content to meet the language, cultural and other requirements of a specific target market (a locale).”

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á

--

--