开发者

Showing IPhone keyboard in different languages based on user input

开发者 https://www.devze.com 2023-01-03 12:34 出处:网络
My question is related to the following question, and can be said almost sam开发者_开发百科e. Setting the iPhone keyboard language

My question is related to the following question, and can be said almost sam开发者_开发百科e.

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消