I want to implement some mechanism to automatically selecting UI language for my Cordova application. The application is also served from the web (i.e. browser).
From what I see, I can either use the Cordova globalization API plugin (here) or, it seems that both Android and iOS support navigator.language which give the device language.
Is there any reason I should opt to use the Cordova plugin over the built in browser/Web View property?
Thanks!
After a series of searches and tests on real devices I can say that the two methods to retrieve the language of the device are more or less the same except for two small differences:
italian
but as region USA
. In this situation, the plugin will return the string it-US
differently by the navigator.language
property which will return the string it-IT
(tested on iOS 11). If you have to know just the language this isn’t a big problem.navigator.language
is not immediately updated. The new setting is available only after the application is killed. The plugin does not suffer os this bug. A workaround could be to use the navigator.languages
property which is correctly updated (tested on Android 5.0.2).If you have to know just the language you can use the information provided by navigator
object without any problem.
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