Sometimes there are multiple languages involved in the product, so you need to set up internationalization. Now, record it. First, if you want to internationalize the product, select Localizations in info under the PROJECT, and click the + number, in this way, the international language version can be added.
After the settings are complete, there will be two more files under your InfoPlist. strings.
Then, you can set some relevant information here.
For example, the program name
// Simplified: CFBundleDisplayName = Chinese app; // English: CFBundleDisplayName = en-app;
In the simulator, you can change the language by setting-universal-multi-language environment-language.
Localized content:
New File... --> Resource --> Strings File. In many tutorials, the File name must be Localizable. strings. Otherwise, it cannot be identified. Actually, it is not. Here we use another method to set the name to MyLocalization. strings.
Then, set the desired field in the corresponding MyLocalization. strings Chinese and English environment, and use NSLocalizedStringFromTable to retrieve the desired text.
// Chinakey = Chinese content; // enkey = en;
UILabel * label = [[UILabel alloc] init]; label. frame = CGRectMake (20, 40,250, 60); label. text = NSLocalizedStringFromTable (@ key, @ MyLocalization, nil); [self. view addSubview: label]; UIView * view = [[UIView alloc] initWithFrame: CGRectMake (20,100,250, 60)]; // judge the current language type NSArray * ages = [NSLocale preferredLanguages]; // obtain the language type NSString * currentLanguage = [ages objectAtIndex: 0]; if ([currentLanguage is1_tostring: @ en]) {view. backgroundColor = [UIColor yellowColor];} else {view. backgroundColor = [UIColor redColor];} [self. view addSubview: view];
If you want different language Environments to correspond to different images, you can also set them. For details, see
If you want to change the image, you just need to right-click showFinder and replace it with an image with the same name. Haha ~~