Showing IPhone keyboard in different languages based on user input

ⅰ亾dé卋堺 提交于 2019-11-28 00:27:16

问题


My question is related to the following question, and can be said almost same.

Setting the iPhone keyboard language

But here are my requirement. I am writing dictionary app for IPhone, which support multiple languages. So my requirement is to display the English keyboard when user has selected English language and show Dutch keyboard when user has selected Dutch and so on.

So i was wondering if this is possible?

I have a hunch that if i "internationalize" the nib, it will display the respective keyboard but not sure.

Thanks.


回答1:


Unfortunately, you cannot control the language of the keyboard. The user chooses which keyboards they would like available via the settings application and can toggle between them using the globe icon on the keyboard. When the keyboard is opened it will open to the most recently used keyboard.




回答2:


What developers need to do in order to create an internationalized app using localized strings:

Basically you create the localized strings for the languages you want to support:

//Localizable.String file for the English version.
"WelcomeKey" = "Welcome!!!";
//Localizable.strings file for the Italian version.
"WelcomeKey" = "Benvenuto!!!";

Then use them in the app:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];

NSLog(@"Current Locale: %@", [[NSLocale currentLocale] localeIdentifier]);
NSLog(@"Current language: %@", currentLanguage);
NSLog(@"Welcome Text: %@", NSLocalizedString(@"WelcomeKey", @""));

// Override point for customization after application launch
[window makeKeyAndVisible];
}

Users can change the language for the keyboard in the settings on the iphone Settings->General->International



来源:https://stackoverflow.com/questions/3032116/showing-iphone-keyboard-in-different-languages-based-on-user-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!