on a multi-lang device, where user can switch the keyboard/language. how to detect what keyboard the user is using? for example, if the user has arabic and english keyboards. how to detect if he is using the arabic or the english one?
is there a way OTHER than checking the input and determine which language is he typing?
by searching on the react native documentation https://facebook.github.io/react-native/docs/keyboard.html there no property or function that provides the actual language of the keyboard , but you can do it by yourself by implementing a function in your java or objective-C code
you can learn here on how to add your personal native code and use it on react native : https://facebook.github.io/react-native/docs/native-modules-android.html
then simply add this method on your "MyCustomKeyboard" class ( java ) :
@ReactMethod
public String getKeyboardLanguage() {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
InputMethodSubtype ims = imm.getCurrentInputMethodSubtype();
String locale = ims.getLocale();
return locale;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With