PDA

View Full Version : Time localization



ds99jove
6 Mar 2012, 6:44 AM
Hi there!

We're having a slight time localization problem, when using the Swedish language and viewing timestamps, they aren't being correctly formated. In Sweden we use 24 hours format, ie. the format "H:i" to display time, but times are currently displayed in a US format using AM/PM.

We're using Ext JS 3.4 and I found localization files under src/locale. After investigating the ext-lang-en.js file I found this part


if(Ext.form.TimeField){
Ext.apply(Ext.form.TimeField.prototype, {
minText : "The time in this field must be equal to or after {0}",
maxText : "The time in this field must be equal to or before {0}",
invalidText : "{0} is not a valid time",
format : "g:i A",
altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H"
});
}


this is missing in ext-lang-sv_SE.js and after adding the following code piece we're getting expected results


if (Ext.form.TimeField) {
Ext.apply(Ext.form.TimeField.prototype, {
minText: "Klockslaget i det här fältet måste vara lika med eller senare än {0}",
maxText: "Klockslaget i det här fältet måste vara lika med eller tidigare än {0}",
invalidText: "{0} är inte ett giltligt klockslag",
format: "H:i",
altFormats: "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H"
});
}


My first point of concern is that it seems incredible to me that noone has noticed this before since the file was last updated (2007 according to comments in it). Do people solve this by setting date format explicitly for every control or why has noone noticed this before? Or is there some other way to set the correct time display format?

My second point of concern is that I'm very hesitant to alter our ext-lang-sv_SE.js since in a project as large as ours it's very likely that sooner or later someone will replace it. I noticed that the localization files for the last Ext JS release (4.0.7) seem to be exactly the same. How can I add this code snippet without riscing that it will be overwritten by the default file? Anyway to override which localization .js file that's being loaded.

Last, how can I submit this "fix" to the sencha team so it will be included in future releases?

Regards,
Jonas Versén

mitchellsimoens
6 Mar 2012, 9:19 AM
Ext JS 4's locale will be going through some changes to work with dynamic file loading.