Closed marklagendijk closed 10 years ago
As soon as this pull request is merged I will create a new pull request with a proposal to change the structure of the locale files. This new format is already commited to my kendo-global branch.
Your approach has its merits, but it requires the traversal of the data structure instead of simply overriding the default kendo objects. We can use your approach to make something that was already requested: on the fly language selection. I'll have to change your code a little bit, perhaps create a "KendoLocalizer" global object that has a method: ApplyLocale(languageCode) so anyone can all it at any time using: applyLocale('pt-BR') for example... But I can only merge it after migrating all other language files...
Edit: I now see that the pullrequest also includes the new format. Apparently something went wrong there, I only wanted to do a pull for the Dutch translations, and after that do a pull request for the updated format.
I can convert all the other language files to the new format, too. I just wanted to know first whether you where open to the idea.
Dynamically loading the specified language file would be quite easy, the only caveat would be that people would need to initialize their Kendo UI controls after the language file would have been loaded:
$(document).ready(function(){
KendoLocalizer.ApplyLocale('pt-BR', function(){
// Init your Kendo UI controls here
}
}
When I find some time (don't know when that will be, yet) I will convert all the other language files to the new format. After that we should find the best approach for dynamiccaly loading a locale file. With the labels already being in JSON format it would be quite easy to support both statically loading a language file (as it is now) and dynamiccaly loading:
I'm experimenting with this: we could create a "kendoLocalizer" object and each individual translation file, instead of applying itself automatically, could just add itselt to the list of available languages on the kendoLocalizer... which would have a single method: Localize(langCode), which would apply the same loop you've already created but to an entry for the language selected...
@loudenvier, thanks for creating kendo-global, it helped me with creating a solution to localize the Kendo controls in my AngularJS app. Here are the Dutch (nl-NL) translations.
My app loads a JSON file with all the resources, and sets the labels for the KendoUI controls with it:
I think it might be a good idea to change the format of the localization files to something like this (1 object containing all the labels, + a simple function to set the labels from this object into Kendo).
I will open an issue about this idea where I will explain it further.