我有一个多语言的应用程序与主要语言英语和第二语言阿拉伯语.
如文档中所述,
android:supportsRtl="true"在清单中添加了.left和right属性start,并end分别.strings-ar(和其他资源类似).以上设置正常.改变后的Locale到ar-AE,阿拉伯文字和资源都正确地显示在我的活动.
但是,每次我导航到
ActivityaWebView和/或a时WebViewClient,语言环境,文本和布局方向都会突然恢复为设备默认值.
进一步提示:
Activity有a WebView和/或a WebViewClient(并且我有几个)时才会发生语言环境的突然转变.它不会发生在任何其他活动上.Android 7.0具有多语言环境支持,允许用户设置多个默认语言环境.因此,如果我将主要区域设置为Locale.UK:
然后在导航到时
WebView,语言环境从更改ar-AE为en-GB.
Android 7.0 API更改:
如API更改列表中所示,API 24中的以下类中添加了与语言环境相关的新方法:
Locale:
Configuration:
但是,我正在使用API 23构建我的应用程序,并且我没有使用任何这些新方法.
此外......
问题也出现在Nexus …
android locale android-webview android-7.0-nougat android-chrome
我的时间格式如下:12/16/2011 3:49:37 PM我得到的格式是:
var newDate = new Date(timeFromat);
timeFormat = newDate.toLocaleString();
Run Code Online (Sandbox Code Playgroud)
我的实际格式是格林尼治标准时间,我使用上面的代码将其转换为我的预订时间.
我想将它改为24小时格式,所以我希望这个日期改变如:12/16/2011 15:49:37我想在javascript中做到这一点.
多数民众赞成我所做的
var firstPartOftimeFormat = timeFormat.substring(0,9);
var secondPartOftimeFormat = timeFormat.substring(10,20);
Run Code Online (Sandbox Code Playgroud)
但是当日期格式如下时它不起作用:3/16/2011.但以下部分有效.
var time = $("#starttime").val();
var hours = Number(secondPartOftimeFormat.match(/^(\d+)/)[1]);
var minutes = Number(secondPartOftimeFormat.match(/:(\d+)/)[1]);
var AMPM = secondPartOftimeFormat.match(/\s(.*)$/)[1];
if(AMPM == "PM" && hours<12) hours = hours+12;
if(AMPM == "AM" && hours==12) hours = hours-12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if(hours<10) sHours = "0" + sHours;
if(minutes<10) sMinutes = "0" + sMinutes;
alert(sHours + ":" + …Run Code Online (Sandbox Code Playgroud)