2 Sep 2011 2:22 AM #1
Ext.LocaleLoader, to dynamically load and apply your locale files (ExtJS + MVC)
I worked on a localization manager / loader recently because I really required a dynamic behavior which fits ExtJS 4 and MVC. I tried the "official" localization examples, as well as the very recently posted "LocaleManager", but it's not what I was looking for. I hope this will help some of you as well
I still need to test it (tested on Google Chrome only) and enhance it a bit more.
I posted the project on GitHub, at this url:
There is an example with it, please try it.
I'd love to get a some feedbacks Thanks!
2 Sep 2011 8:18 AM #2
I won't be able to look into this until next week, but I definitely need something like this : just to let you know that at least one person is interested
2 Sep 2011 5:17 PM #3
Great I'm looking forward for your feedback!
3 Sep 2011 5:34 AM #4
Nice, I can't wait to try this out when I get time. I am going to try it out for more than locale purposes. This may be good for our project specific naming conventionsExtJS 4.0 - Ext.ux.grid.FooterSummary (Coming Soon)
ExtJS 4.0 - Ext.ux.form.field.IPhoneSwitch (Coming Soon)
ExtJS 4.0 - Ext.ux.grid.HeaderFilter (Updates Coming Soon)
ExtJS 4.0 - Ext.ux.menu.DynamicMenu
ExtJS 4.0 - Ext.ux.form.field.ClearableCombo
ExtJS 4.0 - Ext.ux.form.field.FormPanelEditor
ExtJS 4.0 - Grouping Extra Features (Overrides) (Updates Coming Soon)
7 Sep 2011 10:34 PM #5
Who did try it? Can't wait to get feedback on this
19 Sep 2011 8:37 AM #6
Locale on existing ExtJS classes
I'm very interested in your work, but my use case is slightly different, so I don't know if it would fit:
I'm trying to translate existing ExtJS classes. For example, the text on the grid column menu shows "Sort Ascending", and I want to translate that.
On Ext3 I've been including the locale/ext-lang-$language.js file to do that.
On Ext4, I found that Ext.grid.header.Container.prototype contains the string I want to change. But with dynamic loading, just including the locale file doesn't work, since it runs before extjs/grid/header/Container.js gets loaded by the framework. So I get error.
I'm wondering if your code could work for existing Ext classes, and how/where I should put the translations in that case. It would be wonderful if the translation for specific ExtJS file could load just after the actual file.
Thanks in advance
Last edited by nosklo; 19 Sep 2011 at 8:38 AM. Reason: formatting
20 Sep 2011 1:40 AM #7
The right way would be to use the ExtJS locale files for that, for sure. The "LocaleLoader" doesn't take in charge the ExtJS locale files yet but it should... so it will
It's a bit tricky though, it would have to execute the content of the ext-lang-xx.js everytime a new widget class is loaded. I'm not sure how to do this yet, any idea ?
20 Sep 2011 11:42 AM #8
The only way I found to make existing locale files to work is to include ext-all.js thus defeating dynamic loading completely.
I mean, the same ext-lang-xx.js file wouldn't get executed many times over and over again. Instead, we could have a separate locale/xx/ClassName.js file for each existing ExtJS class, and it would get automatically loaded just after the original file.
Ext.grid.Panel would load extjs/grid/Panel.js and the LocaleLoader would kick in, loading locale/fr/grid/Panel.js
What do you think? Is that possible?
20 Sep 2011 6:01 PM #9
- we'd have to make available all the files in locale/xx, for every classes
- there is a neat ExtJS locale file already, we shouldn't create anything on our own, and use this file instead
Let me try to implement this today, and let's see how it works
21 Sep 2011 6:49 AM #10
Also, current ExtJS locale file is incomplete anyway - it seems to come unchanged from Ext3. There are lots of new classes and texts to translate on Ext4 classes that aren't mentioned on the current locale file.
To split the current locale file into multiple files isn't much work, and by doing it we would gain benefits:
- no locale configuration for classes you're not using.
- Ideally, in the final built and minified application, no reference to unused classes would show up since the locale part for those classes wouldn't even get included.
- Seems easier to implement since no run-again trick is needed, we would just adapt your current code to load from different path
Last edited by nosklo; 21 Sep 2011 at 8:38 AM. Reason: more info