In this post, we are going to learn about multi language iOS app support. Follow the below steps to add multi language support to your app. I am assuming that you had already created your project, if not then create it and start following below steps in order to add multi language support.
Step 1: Right click on Supporting Files folder and click New File
Step 2: Select strings file from the drop down window. You can get there by selecting Resources under IOS on left side pane and then chose Strings file. Name it Localizable.strings
Step 3: Select your project (not target) and navigate to info. In the bottom, you will see Localizations, click on + icon and add the language you want your app to be in.
Here, Xcode will prompt you to create localize string files for xib files or storyboard files. This is very helpful if you want to change text of button placed in xib file or on storyboard.(It only works if they are already created prior to localization)
Step 4: Select your Localizable.strings file and on right side in inspector window click on Localize button. It will ask for permission. Select language from drop down menu and click localize.
Step 5: No you will see Russian language file there too under Localizable.string file, select the Localizable.string file and checkmark the english checkbox so that we can set our english strings in that file.
Now, its time to create keys and set there values in both files. You can create keys as shown here
No to use them, you can use below syntax
NSLocalizedString(NSString *key, NSString *comment)
yesEng.text = NSLocalizedString(@"Yes", nil);
noEng.text = NSLocalizedString(@"No", nil);
Here, yesEng and noEng are our IBOutlet to UILable.
Change you simulator/device language to Russian and run your app. If it does not work on simulator then run app on device to get the results.