如何datetime.datetime.now()以母语打印出来?
>>> session.deathDate.strftime("%a, %d %b %Y")
'Fri, 12 Jun 2009'
Run Code Online (Sandbox Code Playgroud)
我想用当地语言得到相同的结果.
给定一个locale java.text.NumberFormat:
NumberFormat numberFormat = NumberFormat.getInstance();
Run Code Online (Sandbox Code Playgroud)
如何在该数字格式中将用作十进制分隔符的字符(如果它是逗号或点)?如何在不使用新的DecimalFormat(格式)的情况下修改此属性?
谢谢
安装最新的Mac OSX 64位Anaconda Python发行版后,我在尝试启动IPython Notebook时不断收到ValueError.
启动ipython工作正常:
3-millerc-~:ipython
Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Run Code Online (Sandbox Code Playgroud)
但是启动ipython笔记本:
4-millerc-~:ipython notebook
Run Code Online (Sandbox Code Playgroud)
ValueError中的结果(带回溯):
Traceback (most recent call last):
File "/Users/millerc/anaconda/bin/ipython", line 7, in <module>
launch_new_instance()
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", …Run Code Online (Sandbox Code Playgroud) 在.NET中,有任何方法可以将三个字母的国家代码(在ISO 3166-1 alpha-3中定义)转换为两个字母的语言代码(在ISO 3166-1 alpha-2中定义),例如.将BEL转换为BE?
在System.Globalization中查看了RegionInfo类,但构造函数似乎不支持三字母代码.
安装我的Android程序后,我检查设备区域设置:
String deviceLocale=Locale.getDefault().getLanguage();
Run Code Online (Sandbox Code Playgroud)
如果deviceLocale在我支持的语言(英语,法语,德语)内,我不会更改语言环境.
但是比如说如果我不支持设备的语言:例如西班牙语.
我将当前的语言环境设置为英语,因为大多数人可以部分理解英语.
Locale locale = new Locale("en");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
pContext.getResources().updateConfiguration(config, null);
Run Code Online (Sandbox Code Playgroud)
但在那之后,在其他方法中,当我检查设备的语言环境时,如下所示:
String deviceLocale=Locale.getDefault().getLanguage();
Run Code Online (Sandbox Code Playgroud)
我得到的结果是"英语".但设备的区域设置是西班牙语.
getLanguage()是否提供当前应用的区域设置?
如何获取设备的区域设置?
编辑:在应用程序的首次运行中,它是一个保存设备区域设置的选项.但是如果用户在保存后更改设备区域设置,则无法知道设备的新区域设置.我只能知道我在app install中保存的语言环境.
我正在将 python 应用程序从语言环境为 en_US.UTF-8 的 ubuntu 服务器迁移到默认设置了 C.UTF-8 的新 debian 服务器。我试图了解是否会有任何影响,但无法在互联网上找到好的资源来了解两者之间的区别。
我机器上安装的窗口具有区域设置en_AU,这就是JasperReports使用的窗口.我已经尝试更改所有用户的区域设置,包括管理员,但它仍然使用en_AU.
我该如何更改该区域设置?是否可以更改REPORT_LOCALE报告中的参数?
我在我的项目和格式化日期中使用Moment.js如下:
var locale = window.navigator.userLanguage || window.navigator.language;
moment.locale(locale);
someDate.format("L");
Run Code Online (Sandbox Code Playgroud)
它运作良好但有时我需要显示没有年份的日期.我不能使用类似的东西,someDate.format("MM/DD")因为在某些语言中它应该是someDate.format("DD/MM").我需要一些想法,L,LL,LLL但没有一年.
我能做什么?
LTS : 'h:mm:ss A',
LT : 'h:mm A',
L : 'MM/DD/YYYY',
LL : 'MMMM D, YYYY',
LLL : 'MMMM D, YYYY LT',
LLLL : 'dddd, MMMM D, YYYY LT'
Run Code Online (Sandbox Code Playgroud) 我正在尝试在R中安装一个软件包,我发誓我的血从未做过,但我在这里.
该命令应该是:
install.packages('NCStats',,'http://www.rforge.net/')` while I am enjoying the healthy dose of:
Warning: dependencies 'nortest', 'plotrix', 'sciplot', 'car', 'gplots', 'gdata', 'Hmisc', 'TeachingDemos' are not available
trying URL 'http://www.rforge.net/bin/macosx/leopard/contrib/2.11/NCStats_0.1-4.tgz'
Content type 'application/x-gzip' length 237120 bytes (231 Kb)
opened URL
=================================================="
downloaded 231 Kb
tar: Failed to set default locale
The downloaded packages are in
/var/folders/Qj/Qjps7xnxFcWdSHsJY3lo+k+++TI/-Tmp-//RtmpzNO8MM/downloaded_packages`
Run Code Online (Sandbox Code Playgroud)
乐叹息.有人知道我怎么能告诉tar我在哪个地方,而不是我理解为什么它需要它或为什么它不能只知道它?
我正在运行OSX 10.6.4和R 2.11.1 GUI 1.34 Leopard构建64位(5589).
使用案例:记录显示给用户的错误消息.
但是,您不希望日志中的消息依赖于用户设备的区域设置.另一方面,您不希望仅为您的(技术)日志记录更改用户设备的区域设置.这可以实现吗?我在stackoverflow上找到了几个可能的解决方案:
但是,它们都会导致更改设备的区域设置(直到下一次配置更改).
无论如何,我目前的解决方法是这样的:
public String getStringInDefaultLocale(int resId) {
Resources currentResources = getResources();
AssetManager assets = currentResources.getAssets();
DisplayMetrics metrics = currentResources.getDisplayMetrics();
Configuration config = new Configuration(
currentResources.getConfiguration());
config.locale = DEFAULT_LOCALE;
/*
* Note: This (temporiarily) changes the devices locale! TODO find a
* better way to get the string in the specific locale
*/
Resources defaultLocaleResources = new Resources(assets, metrics,
config);
String string = defaultLocaleResources.getString(resId);
// Restore device-specific locale
new …Run Code Online (Sandbox Code Playgroud)