Internationalization, localization and pluralization

Jackie Wang
3 min readJan 28, 2021

What is internationalization?

Internationaliztion is often written in English as “i18n”, where 18 is the letters between “i” and “n” in the English word. Internationalization is the design and development that that enables easy localization for target audiences that vary in culture, region, or language. In a simple word, it means “putting in the work to make sure your app works correctly in other language.”

What is localization?

Localization is also known as “l10n”. It means “adding specific languages to your app, e.g. Italian and Hindi.”

How to internationalize our app?

  1. Create a new file called Localizable.string in the project folder
  2. Open Terminal, go to the folder where your .swift files stays and run genstrings *.swift. This will scan the files and creates a lot of key-value pairs for us in the Localizable.string file.
  3. After that, we can replace the hard-coded string in our project with NSLocalizedString.
  4. In Xcode menu, select Edit scheme → Options, tick Localization Debugging, which will make non-localized string in CAPITAL CASE, which is more obvious to be seen.
  5. Then run the project, find out the non-localized strings depending on the CAPITAL CASE and the error log, and fix them.
  6. For double check, select Edit scheme → Options, change the app language to Double-length Pseudolanguage so that the correctly localized strings will be double for you to check.

How to localized your app?

After finishing the steps above, our app is now internationalized, which means it is ready to be localized.

  1. Go to our project settings, select the Info tab and click the “+” button, finally choose the language that you want to localize in.
  2. Select the Localizable.string file, then open the file inspector and press the “Localize” button in the Localization section, finally check the English and other languages you want to localize in.
  3. Xcode will create a copy of the English Localizable.strings for another language.
  4. The next step is to change the values in the strings file for the new language as translated.

After finishing all the steps above, our app is localized. Feel free to change the system language to check the languages out.

One more thing before you leave…

I think you might notice that it will be tricky for the pluralization. For example, if we localized “10 books” as “%lld books” and once we want to put only one book, it shows “1 books”, which is incorrect. And English is using the plural form even when zero items are involves, but there are many language that works in different ways.

Instead of crazily using if-else sentences, we can use pluralization system, .stringsdict file, provided by Xcode. Let’s take “10 books” as an example.

  1. Create a new file using the Stringsdict file template, calling it Localizable.stringsdict.
  2. Replace “StringKey” with “%lld books.”
  3. Underneath zero, put “No books” in.
  4. Underneath one, put “1 book” in.
  5. Last but not least, underneath many, put “%lld books”in

That’s all you need to do, and Apple will handle the pluralization for us!

--

--