Want to dynamically load locale files? Ext.LocaleManager can load a JS script tag on the fly.
Want to refer to locale text easily in your application? Ext.LocaleManager has a simple get method that you can use to access locale text even if the text is nested.
https://github.com/mitchellsimoens/Ext.LocaleManager
Easy to setup and use:
Code:
Ext.LocaleManager.setConfig({
language : 'en', //default is 'en'
ns : 'locale', //default is 'locale'
path : '/locale' //default is 'locale'
});
Ext.onReady(function() {
var callback = function(manager) {
console.log(manager.get('helpText'));
console.log(manager.get('button.action'));
};
Ext.LocaleManager.loadLocale(callback);
});
Sample locale looks like:
Code:
{
helpText : 'Click me for help',
buttons : {
action : 'Action'
}
}
On my wishlist:
- Get into the Ext JS 4.x framework
- Support Ajax loading, not just script tag loading (Added 8/5/11)
- More advanced locale settings like date differences
Updated (8/5/11):
- Ajax support! (need feedback)
- Default text parameter on get method
- New Ajax example
- Update Simple example to show default text usage
- Updated MVC app example to have a language ComboBox