iPhone: Change Keyboard language programmatically

change keyboard language swift
android change keyboard language programmatically
change keyboard type ios
swift change language programmatically
how to change keyboard language in iphone xr
change keyboard type xcode
iphone keyboard language
ios change language at runtime swift

I am trying to provide a different language support on my iOS 5.x application whenever native Keyboard is opened. Provide this language in native keyboard programmatically. Could someone guide me how can i support it? I saw a carbon framework, but looks like its for Mac apps.

Thanks.

No this is not possible - user can only change their language in the settings.

However you can give the user an "English" keyboard if you choose (or ask them their preference)

you do this using: UIKeyboardTypeASCIICapable

You can change keyboard directly on the keyboard by pressing "globe icon" on the bottom row.

First, you have to enable those language for input in Settings. Then pressing the globe button on the keyboard would toggle between those languages.

iPhone: Change Keyboard language programmatically?, Thanks for this tutorial. Generally what we are doing is that first add some languages to keyboard by going to settings>general>keyboard  Set typing features. You can turn on or off special typing features—such as spell check, auto-correction, and auto-capitalization—that assist you when you type on iPhone. While typing text, touch and hold or , then slide to Keyboard Settings; or go to Settings > General > Keyboard. In the list, turn special typing features on or off.

You can do it starting from iOS 7 on a per UIResponder basis. There is textInputMode property in UIResponder class. It is readonly, but the documentation says:

The text input mode identifies the language and keyboard displayed when this responder is active.

For responders, the system normally displays a keyboard that is based on the user’s language preferences. You can redefine this property and use it to return a different text input mode in cases where you want a responder to use a specific keyboard. The user can still change the keyboard while the responder is active, but switching away to another responder and then back restores the keyboard you specified.

In my project I created a subclass of UITextField and defined a new property called userDefinedKeyboardLanguage. I also overrode above mentioned textInputMode method. It looks similar to the following:

- (UITextInputMode *) textInputMode {
    for (UITextInputMode *tim in [UITextInputMode activeInputModes]) {
        if ([[Utilities langFromLocale:userDefinedKeyboardLanguage] isEqualToString:[Utilities langFromLocale:tim.primaryLanguage]]) return tim;
    }
    return [super textInputMode];
}

I have also a custom method +(NSString *)langFromLocale:(NSString *)locale in my Utilities class which looks like this:

+ (NSString *)langFromLocale:(NSString *)locale {
    NSRange r = [locale rangeOfString:@"_"];
    if (r.length == 0) r.location = locale.length;
    NSRange r2 = [locale rangeOfString:@"-"];
    if (r2.length == 0) r2.location = locale.length;
    return [[locale substringToIndex:MIN(r.location, r2.location)] lowercaseString];
}

Now my custom textfield class can change the keyboard input language simply by setting userDefinedKeyboardLanguage property to the desired language.

How to programmatically add languages to keyboard in ios?, What you are observing is not really random. It is programmatically possible to remember the last used keyboard language, from among the set  iphone - changing language programmatically - Stack Overflow I'm developing an iphone app and want to have the option to programmatically change the language. For example the user can change the language for spell checking and auto-correction by tapping on the

I know it is old question, but here it is my way to change keyboard language.

Thank to @the4kman for the mark: this way can change current keyboard only to those which were added in Settings.

Swift 3:

class CustomTextField: UITextField {

    private func getKeyboardLanguage() -> String? {
        return "en" // here you can choose keyboard any way you need
    }

    override var textInputMode: UITextInputMode? {
        if let language = getKeyboardLanguage() {
            for tim in UITextInputMode.activeInputModes {
                if tim.primaryLanguage!.contains(language) {
                    return tim
                }
            }
        }
        return super.textInputMode
    }

}

iPhone: Why does the keyboard language switch randomly?, Change keyboard language programmatically. GitHub Gist: instantly share code, notes, and snippets. Open the Settings app then go to “General” and “Keyboard” Choose “Keyboards” and select “Add New Keyboard” – tap on any alternate language keyboard to add that to the list of available keyboards in iOS which you’ll then be able to gain quick access to

Declaration:

@IBOutlet var yourTextField:cTextField!;

Use:

yourTextField.languageCode = "ru";

Class cTextField:

class cTextField: UITextField {

    // ru, en, ....
    var languageCode:String?{
        didSet{
            if self.isFirstResponder{
                self.resignFirstResponder();
                self.becomeFirstResponder();
            }
        }
    }

    override var textInputMode: UITextInputMode?{
        if let language_code = self.languageCode{
            for keyboard in UITextInputMode.activeInputModes{
                if let language = keyboard.primaryLanguage{
                    let locale = Locale.init(identifier: language);
                    if locale.languageCode == language_code{
                        return keyboard;
                    }
                }
            }
        }
        return super.textInputMode;
    }
}

Change keyboard language programmatically · GitHub, I am trying to provide a different language support on my iOS 5.x application whenever native Keyboard is opened. Provide this language in native keyboard  You can add the keyboard language in Settings, General, keyboard, and then International Keyboards and then select the Keyboards option to add a new iPhone language keyboard. Select the desired keyboard language from the available list by turning it on.

This seems to work to change, for instance, to a Greek keyboard:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"el", nil] 
    forKey:@"AppleLanguages"]; 

[[NSUserDefaults standardUserDefaults] synchronize]; 

Is there a way to change a the users preferred keyboard language , to (with the users permission) change their preferred keyboard language for them? I didn't find many tutorials on the internet as I found for iOS, however,  How to add and switch keyboard language on iPhone or iPad. To add keyboard language, you can do this following steps: Step 1: tap Settings. Step 2: Tap General. Step 3: Tap keyboard. Read also-How to Activate and Use Hot Corner on Mac. Step 4: Tap Keyboards. Step 5: tap Add New Keyboard. Step 6: on OTHER IPHONE KEYBOARD choose keyboard language. Yup!

Managing the Keyboard, Describes the technologies and techniques for displaying and managing text and web content in iOS. How to Switch Keyboard Language on Android. This wikiHow teaches you how to switch languages in Gboard, the default keyboard app on most Androids. Open an app that uses the keyboard.

How to Change the Keyboard Language on iPhone & iPad Quickly , I am trying to provide a different language support on my iOS 5.x application whenever native Keyboard is opened. Provide this language in  How to change keyboard language on Android ? Android is such a popular operating system for smartphones and in the world, people often find that they need to change the keyboard to a different

How to change the keyboard language on iOS. Whether you're a multilingual iPhone or iPad user or just learning a foreign language, you  Add a language. When you change languages with Gboard, your Android device's language settings aren't affected. On your Android phone or tablet, install Gboard. Open any app that you can type with, like Gmail or Keep. Tap where you can enter text. At the top of your keyboard, tap Open features menu . Tap More Settings .

Comments
  • @Getsym, Please update the selected solution.
  • Hi, So, i can't programmatically allowed to change the keyboard language to different even with latest SDK also? I may show only english language keyboard if required to show a keyboard in within my app? Could you please provide me any apple link saying this is not possible, so i can read it more clearly, thank you very much.
  • I saw there is an option to 'Add New Keyboard..' in Keyboard settings on the iPhone. Can't we even install our own language file into it through our program or iTunes sync?
  • Yes in that we can't insert our own language
  • Maybe in 2012 it was not possible. Now by overriding textInputMode it is possible. See kotvaska answer. It works even for ios 11 :)
  • In 2012 it was not possible. It became possible after by overriding textInputMode. However as of September 2019 with iOS 13 textInputMode's return value is ignored.
  • Great! This should be the answer.
  • My project is in Swift, but I found I needed to drop back to ObjC to override textInputMode.
  • how to ovverride textInputMode in swift?
  • This should most definitely be the answer.
  • Brilliant. But there's a problem (not your fault). If the user switches the keyboard to another language, the keyboard language continues to be reported, wrongly, as the tim language.