I'm done. My improvements:
Most of my comments and changes are described in the commits and code. Code is mostly equal to what ssamayoa has posted.
- Allow for language change after language change after language change etc.
- Go back to original language using initialConfig
- Localizable grid values through column renderers!
- When components need tooltips, I usually add them as a tip property to the same component. That tooltip can be translated as well.
- Prevention against word wraps after translation that I have seen occuring.
- upgrade to latest build of SA (442)
- Use ExtJS from cdn.sencha.io
- renamed locale file to js, because IIS for example can't read .json files by default. (just to make it easy to test run this)
This is work in progress and needs further optimization. Specially in the area of configurability.
Check it out, improve it and update it on Git . I will too. Thanks.
Awesome!! As soon as I find a minute I'll check it out. Thanks!!
Hi, it's already been a little while since the last reply to this post but I'd like to share what I did in this regard (Localization) with my project.
I started referring to all the localizable strings by a variable name:
And then I created a file for every language in the application with the translations:
var header = Ext.create( 'Ext.TitleBar',
id: 'header', docked: 'top', title: titleName, cls: '', html: htmlHeaderContent
Then in the html file I can either check the language of the browser, or create a language selection screen, and decide which file to load.
var titleName="English title";
var htmlHeaderContent="Html content in English";
var titleName="Título español";
var htmlHeaderContent="Contenido en español";
I find this way pretty easy to use and maintain.
the basic concept is quite good, but you are poluting the namespace by defining lots of global variables, this is not good. So I would recommend you the above posted solution using the Localizer.
The namespace pollution alone is not a valid argument to use Localizer. He might as well use Ext.translations.titleName="Título español";
Originally Posted by devtig
But Localizer is meant to be use with existing applications and with applications crafted with Sencha Architect.
Yes, I agree. I still use Localizer with projects I create with Sencha Architect today.
Yeah, this is true. I keept my explanation a little short. I didn't wanted to specifically recommend Ext.ux.Localizer, I wanted to recommend the concept of a localizer.
Since I'm using CakePHP as a backend I have my own implementation in Bancha. I have a shell task which collects all translatable strings and writes them all in a pot file (A catalog of all translatable strings, supported by a lot of fancy translation tools). When I then open my WebApp the localizer pulls the correct language translations, afterwards each call of Banacha.t('Hello %s, good to see you', name) will be translated and returns the localized version.
Besides the advantage of having very readable code and having good tools to update and manage translations over time, I'm able to outsource specific translations.
Sencha Architect 2.2 (coming soon) will include a new feature called process config.
This allows you to integrate ideas like Localizer much more easily. More details to come from the author of this feature.