Faults of iOS App Localization

Sergey Vakhramov
Symboji Keyboard
Published in
5 min readApr 26, 2019

Hello.

I’m just a beginner in an iOS Development. And I have decided to make my first app as a Keyboard Extension — keyboard, which will allow you to fastly type shortcuts’ symbols on your iOS device.

After I’ve done the app, my friends who don’t know English, asked me every day like: “Please, translate it. Please-please-please.”

Once I decided to do it. Let’s localize the app.

The main thing you’ll do at first is to open Google and ask it for something like “how to localize an ios app”. I did the same.

I’ve localized. As you can see, what I’ve got was far away from what I was expecting for.

Preparations.

Probably, you’ve started with going into “Project → Info → Localizations…” and added a new one:

Project → Info → Localizations…

Then you activated it in File Inspector:

Localizations of a specific file

And got a new .strings file:

Strings file

Which contains dictionary where the key means Storyboard Object ID and assigned value of a new translation.

Strings file content example

Okay. Let’s try to localize:

Edited strings file

And you’re done! Just start your app, change the language in “Product → Scheme → Edit Scheme…” to prevent it from the necessity of manual changing from the Simulator’s menu.

Product → Scheme → Edit Scheme…

Running the simulator.

And look at the results:

Surprise!

You and I expected to see fully-localized screen. But what we see is a disappointment.

I googled this and found only the one article on Stackoverflow which says that this bug exists since beardy versions of iOS. There’re no solutions to solve this problem. Oh, sorry, there are.

Anything else?

You can transform your strings file, for example, into a Storyboard. You can try this, but I bet you’ll drop this solution.

Why? Just because when you modify the main Storyboard file (move views, change label captions, etc.), localized ones won’t be updated. Also, if you want to update the strings in code, there’s no way to do that automatically.

In conclusion, I highly recommend you not to use these ways to localize your app.

My way of localizing the app.

Why? Just because I haven’t found an acceptable solution on the Internet in one simple article which will provide you from adding new language to your project to finally opening the app in Simulator and feasting your eyes on the app.

The guidelines

  1. Let’s use nested naming for keys. For example, instead of using names like “BACK_BUTTON_TITLE”, we’ll use “MainScreen.Back” which describes “WhereTranslate.WhatTranslate”.
  2. Make a String class extension to get the localized string from .strings file.
String extension which allows you to get a localized version of a string

Adding .string file to the project

Open “File → New → File…”.

Choose “Strings File”:

Adding new file (first step)

Then name it “Localizable”:

Naming the file (second step)

So, we’re done! Just add new localization in File Inspector and you’ll see different variaties of .strings file you’ll have to localize.

Make some magic and fill in the file:

Localizable.strings

Localizing

So, to use this approach, create outlets for the views which you want to localize.

Our @IBOutlets to be translated

And use our string extension to get the translated versions of the strings.

Example of use of .localize() method

Using this approach you also can translate formatted strings:

Example of formatted string initialisation

Simulator, how’re you doing?

Don’t forget to use your new localized() method.

Try opening the app and enjoy the results:

Successfully translated application

Localization of an iOS Bundle

Oh… This is one story about that. It doesn’t work in XCode now. Just doesn’t work…

To localize the bundle use your hands.

Go to the project folder, choose the bundle and right click “Show Package Contents”.

Where to click to get inside the bundle

Copy “en.lproj” folder and rename it in a way related to the language which you want to add.

Adding folder with Russian language translations

The folder should contain “Root.strings” file.

Call the Wizard and make some Magic

Restart Xcode to apply changes.

Now you’re able to localize your Bundle.

Bundle localization

Thank you!

Hope, I helped you a lot while localizing the app.

--

--

Sergey Vakhramov
Symboji Keyboard

Junior iOS Developer (Swift)📱 • Blockchain Adept 🔗