简体   繁体   English

Ext.js日期格式区域设置

[英]Ext.js Date Format Locale

I put the format to be (M d, Y) where I want it to be "Nov 20, 2013" works great in English. 我将格式设置为(M d,Y),我希望将其设置为“ Nov 20,2013”​​,英语效果很好。

The problem is - when I use different locale on the page, it does direct translation and not change the format to a format that is used in that location, for example, when I use Chinese it just transalte the word November. 问题是-当我在页面上使用不同的语言环境时,它会进行直接翻译,而不会将格式更改为该位置所使用的格式,例如,当我使用中文时,它只会翻译11月一词。 and not change the structure of the date. 而不更改日期的结构。

any suggestion what can I do to overcome this issue? 有什么建议可以解决这个问题?

If you're providing your own date format (eg for a date field) then this format will be used, no matter if it is appropriate for the current location or not. 如果您提供自己的日期格式(例如,日期字段),则将使用此格式,无论它是否适合当前位置。

Assuming you're using a locale file ext-lang-*.js , you can use the property Ext.Date.defaultFormat , which will contain the format code of that locale. 假设您正在使用语言环境文件ext-lang-*.js ,则可以使用属性Ext.Date.defaultFormat ,该属性将包含该语言环境的格式代码。

Alternatively, you can also set the value of that property yourself: 另外,您也可以自己设置该属性的值:

Ext.Date.defaultFormat = 'Y-m-d'; // your format here

EDIT: I just had a look the chinese language files and it seems that they do not set a defaultFormat, so you will have to set it yourself (as described above). 编辑:我只是看了一下中文文件,似乎它们没有设置defaultFormat,所以您必须自己设置它(如上所述)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM