Post

Replies

Boosts

Views

Activity

Reply to Change the Language of my current input keyboard programmatically in iOS and MacOS
Hi Ziqiao, please refer to the comment I have added below this post. I have detailed out some further questions. In short: I have used the primaryLanguage property in UITextInputMode to achieve some similar functionality. This seems to work well for a particular TextField, however, this is TextField specific and not app-wide. Is there any way to change the input language for the entire app? Secondly, coming to MacOS, is there something similar to iOS above in MacOS?
Topic: UI Frameworks SubTopic: General Tags:
Jul ’25
Reply to Change the Language of my current input keyboard programmatically in iOS and MacOS
Hi Ziqiao, While the method works for the case of "remembering" a language for the textfield. It did not work for getting the keyboard itself to change the language. I have this method in UITextInputMode to achieve some similar functionality: override var textInputMode: UITextInputMode? { for inputMode in UITextInputMode.activeInputModes { if let primaryLanguage = inputMode.primaryLanguage, primaryLanguage.hasPrefix(targetLanguageCode) { print("This will return Arabic if 'ar' or English if 'en'") return inputMode } } print("Target language keyboard not found. Falling back to default.") return super.textInputMode } This seems to work well for a particular TextField, however, this is TextField specific and not app-wide. Is there any way to change the input language for the entire app? Also, please let me know if the above implementation is all right and will be allowed in production apps. Secondly, coming to MacOS, is there something similar to the above UITextInputMode that allows me to return a primaryLanguage like this? If not then can we use the Carbon Framework's Input Source method to achieve similar functionality? I understand that Carbon has been deprecated but these APIs seem to work? Are we not allowed to use these APIs? There is no documentation for these APIs as it has already been discussed in this thread, but there seem to be no answers here too: https://developer.apple.com/forums/thread/124268?answerId=389152022#389152022 Are we allowed to use these methods or will this cause problems while publishing the app?
Topic: UI Frameworks SubTopic: General Tags:
Jul ’25