Turn: http://blog.csdn.net/samuelltk/article/details/8480403
I upgraded to xcode4.5 a few days ago. Now I am using xcode4.5 + ios6 Development Project. When I was using internationalization, I encountered a problem. I created localizable in xcode of the previous version. after strings, the "+" Number of the added language disappeared. After half a day, I did my research and found a solution on stackoverflow, apple changed the "+" number to a place. Next let's take a look at how to use it.
Create a resource file named localizable. Strings
After the file is selected, multiple buttons are displayed in the property selector:
After clicking this button, the international language selection box appears, but there is only one option for English:
It doesn't matter. Continue. Click localize. Only English is supported. In versions earlier than xcode4.5, there will be a "+" number in the attribute selector to add support for other languages. Now it's gone, but it's actually somewhere else. Click the project root directory, select project, and select the info tab. The localizations is displayed at the bottom:
Click "+" and select a language to add. Here I select "Chinese" and "OK". Now, let's look at localizable. the strings file has two more sub-files, which support both English and Chinese:
English and Chinese are also seen in the attribute selector:
In this way, the settings and operations for internationalization on xcode4.5 are completed. The following describes how to use them.
Select the localizable. Strings (English) file and add the following content:
"Loading"="Loading ...";
Select the localizable. Strings (Chinese) file and add the following content:
"Loading"="Loading...";
Note that the content must end with a semicolon; otherwise, it cannot be recognized. ThenCodeUsed in:
Nsstring * loading = nslocalizedstring(@ "Loading",@"");
The system will identify whether to use Chinese or English based on the language environment of the current device. At this point, the international operation on xcode4.5 will be completed.
If the name of The. Strings file is localizable. strings, you can use the following method to call it:
Nslocalizedstring (@
"Title"
, Nil)
The two methods have the same purpose:
- Nslog (@ "Local string0: % @", nslocalizedstring (@ "str0", nil ));
- Nslog (@ "Local string1: % @", nslocalizedstringfromtable (@ "str1", @ "localizable", nil ));
If the. Strings file is created with a custom name, for example, internation. Strings, the call method is as follows:
Nslocalizedstringfromtable (@ "title", @ "internation", nil );
The nslocalizedstring method does not work after the User-Defined name. Note the following;