我为 iPhone 制作了一个应用程序。在此用户可以在按钮单击时更改语言。但 NSLoalizedString 没有转换值。
代码是
-(IBAction)btn1pressed:(id)sender {
SecViewController *sec = [[SecViewController alloc] initWithNibName:@"SecViewController" bundle:nil];
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
// NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
languages =@"en";
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
// NSLog(@"%@", NSLocalizedString(@"Subhash", nil));
[self.navigationController pushViewController:sec animated:YES];
}
-(IBAction)btn2pressed:(id)sender {
SecViewController *sec = [[SecViewController alloc] initWithNibName:@"SecViewController" bundle:nil];
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
// NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
languages = @"es";
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
// NSLog(@"%@", NSLocalizedString(@"Subhash", nil));
[self.navigationController pushViewController:sec animated:YES];
}
-(IBAction)btn3pressed:(id)sender {
SecViewController *sec = [[SecViewController alloc] initWithNibName:@"SecViewController" bundle:nil];
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
// NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
languages =@"ja";
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSLog(@"%@", [userDefaults objectForKey:@"AppleLanguages"]);
// NSLog(@"%@", NSLocalizedString(@"Subhash", nil));
[self.navigationController pushViewController:sec animated:YES];
}