View Full Version : Pros and cons of localization implementations

1 Feb 2013, 8:20 AM
I've noticed that the way localization is done in Ext JS and the examples provided use a localization file that overrides the different classes in your application. The way I was going to do it was to create localization files, load the appropriate one, and then in the files that need to be localized I'd just use NP.locale.labelText.

I see one pro and con for each approach. With the Ext JS approach, your component is not dependent on anything else, it works out of the box (with whatever default language you use in it) and just gets overridden. The disadvantage is you need to include a whole bunch of labels as config options, making the code needlessly long.

With the approach I was thinking of going with, the advantage is that you don't need to have all your labels in your component's config options, you just directly use NP.locale.labelText in the component. The downside is you create a dependency to something else, though a simple one to resolve.

Are there any other pros and cons to these approaches? Any other good ways to implement this?

4 Feb 2013, 1:03 PM
First understand that as a general question, localization can be very complicated.

The framework takes a very simplified approach (the override approach) and does work but as you said things can get quite large as everything has to be a property and then you have to build your items within methods to get the scope to get that property. Also, it's 2013 so people expect things to happen magically. If you load a new locale using the override approach you have to reload the page to get everything to use the new locale strings everywhere (new component instances will use them but that's new instances, current ones will not magically reflect the new strings).

I'm not trying to sell you on my manager as it's not one size fits all. What I do with Ux.locale.Manger (https://github.com/mitchellsimoens/Ux.locale.Manager) is I have a set of overrides on teh components that can change the text dynamically. This way it can then allow a user to select a different language, it will fire an Ajax request to load the new locales and then get all the components that are "localable" and executes the setLocale (added in the component overrides). Like I said, not trying to sell you, just what I personally liked and works for my applications.