Basically Internationalization is the process of translating an iOS application in different languages. It is a two step process. First you have to prepare your app by separation all user-facing text that need to be translated from the rest of your code and storyboards. Next thing you have to do is to prepare translated text files and your app is ready to support another language.
Lets learn this step-by-step by preparing a demo application.
Step – 1 :- Create XCode Project
First of all create an XCode project & design your storyboard.
Step – 2 :- Turn On base internationalization
Recent versions of xcode turn on base internationalization by default. To check it in your project, go to your project’s info tab. You will see “Use Base Internationalization” checked under Localization section.
Step – 3 :- Add languages that u want your app to support.
Tap on “+” sign under localizations section in info tab to add languages.
This process will add .strings file under your Main.storybaord file which will contain all texts existing on your storyboard. This .strings file will be generated individual for each language you add to support your application.
Step – 4 :- Translation in particular language.
Now suppose you are adding French language to your application. This will create Main.strings (French) file which will contain all texts that is in the storyboard. Basically it will look like below.
Here you have to translate all texts in French language. So now .strings file will look like below :
Lets understand the format of this file. There is two lines for each control on the storyboard that contains text. First line contains the class of particular control, its text and its objectId. You can find objectId for particular control in Identity Inspector in Utilities pane as shown in below figure :
The second line in the file contains actual translation of the text. The format to set the text is
. = ;
NOTE :- If you are adding any textual control on the storyboard after .strings file is generated, you have to add two lines for this control manually in .strings file with specific format as explained above.
Till now we have only translated texts that exist in storyboard. Now you may have one question that what about the texts that we display in our application through code? So lets now have a look on the solution of your question.
You have to add Strings file in your project. You must name this file as Localizable.strings file because xcode won’t find strings file with other name.
Now select this file from navigator and localize it from file inspector.
When you tap on Localize button, it will ask you to localize the file. Select Base and Localize it.
This will list all languages you have added from your project info panel. Checkmark the languages that you want for your coded display text.
It will create Localizable.strings file for each language you have checked in list.
Select Localizable.strings (French) file and add all texts that you are going to display in your application by coding. You have to maintain below format for this.
Now your app is ready to support French language. To test your app in French language, change your device/simulator language to French and run the application. You will find all text in French language.
This is all about internationalization and localization of application.