问题
In iOS, despite changing the language settings WL.App.getDeviceLanguage() always returns en
.
Tested on iPhone 5, iPad 4 and several emulators.
If use navigator.globalization.getPreferredLanguage could detect language correctly in iOS. But the application seems not know it is under other language such as French so application name local string is still in English even other language is available.
回答1:
When using iOS, the relevant setting is that of Region Format.
- Created a new Worklight project and application with the iPhone and Android environments
- Added in
wlCommonInit()
:alert(WL.App.getDeviceLanguage());
- Build All and Deploy, launch in device
In iOS
There are two settings related to language:
Settings.app >> General >> International >> Region Format
I currently have
Hebrew (Israel)
selected.
Launching the app shows me an alert withhe
.Changing to
Gusii (Kenya)
and re-launching the app then shows megu
, and so on for other region formats.Settings.app >> General >> International >> Language
Changes done here will take no effect.
In Android
There is only one setting related to language:
Settings >> Language and input
I currently have
עברית
(Hebrew) selected.
Launching the app shows me an alert withiw
.Changing to
English (United States)
and re-launching the app then shows meen
, and so on for other languages.
来源:https://stackoverflow.com/questions/17764511/ibm-worklight-wl-app-getdevicelanguage-api-method-does-not-return-correct-la