It is quite simple as soon as you understand it.
The first thing you want to do is add a localization file to the project. To do this, simply select the main project group
,
then on the toolbar, select File → New → File... (or just hold ⌘N )
.
In the Resource category, select Strings File
, and name it Localizable.strings (note that it is case sensitive)
.
Now that we have a localizable file, we can click the Localize... button in the File Inspector
.
Xcode will ask you if you want to localize the file, just click Localize with Base
.
Now this next part is a bit complicated. We need to enter our Info project to do this, click the project file in Xcode Navigator , then on the right you will see a category called PROJECT , click on the project file under this category
.
Now we can add the desired language in the Localizations category. I will add Norwegian
.
It is important that we leave our Localizable.strings file in the menu that appears
.
Now we can deploy our Localizable.strings file in Navigator to see our localized files
.
Now we are like our Base file (in our Localizable.strings file), which will be our "main language" of our application and our previously selected language.
It is important to know that the structure of these files must be the same. You will see what I mean in just a second.
In our Base I will add a line called it_worked and add its localization
.
And in our previously selected language (in my Norwegian case) I will add the same it_worked line (to save the structure), but with a different localization
<T411>.
Now that we have our localized file, we can make our application read when necessary.
I added the UILabel application to my application so that we can display localized text in our application.
[myLabel setText:NSLocalizedString(@"it_worked", nil)];
Now, if I run the application, we will see our base language
,
and if I change the language of the simulator to Norwegian, we will see our other language
.