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: