Every app has some static text. Either as a title of a screen or as a title of a button, or just as plain text. In most of the cases we can see them inside nib files or as hardcoded values inside Swift files.
Many times this approach can be very messy and can lead in a lot of unnecessary work to maintain the project and to add or mostly change some text in the app. A requirement to gather all the static text of the app and give them to the legal department in order to review them, or a requirement to localise the text in another language are maybe not so common but for sure can happen. Also if suddenly the UX team wants to change the messages of all the “close” buttons can be very painful if all the static is not in one place.
Fortunately we can plan ahead and introduce localisation from the beginning or at least the sooner the better , if the project is not greenfield. Xcode provides an easy way to achieve it.
Let’s assume that we have the following view:
In order to add localisation we have to tap on the project file and create a String resource. Name the file as “Localizable”. Then all we have to do is to add the static text strings in this file:
And as final step we have to replace the static text to our localized strings: