Unanswered: MVC with dynamic loading and... i18n ?

Unanswered: MVC with dynamic loading and... i18n ?

I would like to translate my ExtJS application in different languages. My issue is that I'm using ExtJS MVC framework, and most of my JS files are downloaded dynamically by the framework itself.
The ideal solution (that I thought of) would be to have an extra option in the Ext.Loader (or in my Ext.app.Application) that would define the language to use, and depending on this to automatically download such file as "a.MyClass.fr.js" after loading my "a.MyClass.js" (which would contain an Ext.apply, overriding my string resources). That's probably not available in the ExtJS framework at the moment.
The alternative solution I can see, is to perform a trick on the server-side. First, a cookie would be created on the client, to set to the language. On the server-side, I could catch all the requests to JS files, then if a cookie is set (='fr' for example), I'd combine the requested JS file (MyClass.js) with its i18n's friend (MyClass.fr.js) dynamically on the server and return the result. That would work, but it's really tricky because it implies other things (caching...).
Maybe the best way is to implement the first behavior I described in the ExtJS framework myself...
What do you think? I'm looking for a really clean and neat way of doing it! Thanks

It's actually a test environment, I can + enjoy to use dynamic loading, and it's pretty convenient within the MVC framework as well. So that would be another issue / question

I could use Ext.require, but... with what? Where? I don't know when my file ("MyClass.js") is going to be loaded, and I need to apply my localization right after it (apply).

It would be nice to have an "afterload" listener on the Ext.Loader: I could then have a handler on it, which would actually call Ext.require with my localized filename ("MyClass.fr.js").

The hierarchy of folders within the MVC framework is quite strict and nice (controller / model / store / view...), but it would be nice to have a "i18n" folder that would be managed as well as the rest.

Mmm, I would have to add those "require" on all my classes then, manually. I could maybe create a patch (Ext.apply) on the Ext.Component (right before to create my Application), so that the constructor will check if there are any "require" to perform. Wouldn't be too hard and too dirty, isn't it?

This needs more work, you most likely don't want to load a resource file for EVERY class in the application including Ext classes.
Besides, if a resource file is missing, the class loading process will break (since it is a *required* dependency).

Sorry I didn't come back earlier with a reply, mberrie. That's definitely what I was looking for, thanks very much for that ! And it lead me to read all the articles about ExtJS 4 Class system all over again I'm still working on my i18n dynamic loading, it's a bit tricky, but I may come with a solution very soon. I'll post it asap, then later I'll need your help to make it better and really helpful for more developers.

Okay, here is my first attempt to do this. It works in my environment. This code must be loaded at the beginning, then there is some documentation at the beginning (it should be enough). I am going to enhance it now, and to test it a bit more, but please try it on your side too I'll upload it on github or somewhere else later.