fis*_*ato 7 android localization
http://web.archiveorange.com/archive/v/fwvde0wN3xcViMtADw6x
似乎navigator.language属性在androids的webview中总是"en".那么,获得用户语言的最佳方法是什么?在原生java代码中获取它并通过javascript将其转换为webview?或任何其他更好的方式?
我发现这个问题的解决方案是通过 webview 的设置来设置用户代理:
WebSettings settings = wv.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUserAgentString(Locale.getDefault().getLanguage());
Run Code Online (Sandbox Code Playgroud)
然后在您的网络内容中通过以下方式检索它:
var userLang = navigator.userAgent;
Run Code Online (Sandbox Code Playgroud)
这应该仅用于显示本地内容的网络视图。
| 归档时间: |
|
| 查看次数: |
8324 次 |
| 最近记录: |