1. Right-click localizables in the Custom Resources Directory, select new file,
Select the strings file of the resource.
Click Next. The file name is defined as "localizable. Strings". Select the directory you want to save and create
2. Select the localizable. Strings file.
On the tool panel on the right, click "+" to add English and Chinese, respectively,
The directory structure on the left is changed
The corresponding directory will generate two corresponding English EN. lproj and Chinese zh-Hans.lproj directory, and the corresponding localizable. Strings File
As follows:
3. Localization
Localizable. Strings uses the key-Value Pair list method to localize applicationsProgramData
Format:
"Key" = "value ";
Enter the colon (:) and equal sign (=). When the score is good, the values must be in English.
For example:
Write in the localizable. Strings (English) File
"Testkey" = "test ";
Write in the localizable. Strings (Chinese) File
"Testkey" = "test ";
When using nslocalizedstring, you only need to call the system macro nslocalizedstring to set irrelevant string data using language.
Format:Nslocalizedstring (@ "key", nil)
For example:
Label. Text = nslocalizedstring (@ "testkey", @ "is test ");
The first parameter of nslocalizedstring is the corresponding key name, and the second parameter is a custom description. You can use Nil
4. localized application names
Edit info. plist and add the application has localized display name. Set the value to yes.
If the program automatically generatesInfoplist. Strings file. If no file exists, create one and perform steps 1 and 2.
Cfbundledisplayname values are defined in infoplist. Strings (English) and infoplist. Strings (Chinese) respectively.
"Cfbundledisplayname" = "app name ";
"Cfbundledisplayname" = "app name ";
Set the default value to Chinese: Edit info. plist, add the localization Native Development Region item, and set it to China.
5. The image is similar to the XIB file localization, you can also add the Same Name image file and XIB file in the corresponding en. lproj and zh-Hans.lproj directory
Add files to the project list