View Full Version : Localizations and const files

11 Oct 2013, 2:41 AM
I'm using Architect and I'm trying to load a file that contains constants and also another file for localizations.
So for example I wish to have a file that will contain the custom event names so that when I use custom events and if at some point I need to change the event name I only have to change it in one place.

this will let me do myView.fireEvent( MY_CUSTOM_EVENTNAME_HERE, ... )

Also I wish to have a localization file.
So any labels etc will refer to the constants in the localization/property file. this file at the moment will not need to be swapped at runtime - although that would be nice. Will have a default file, but will no doubt load the correct property file using a parameter in URL or similar.

Any pointers or help?
(I'm using Ext JS 4.2.2 if that makes any difference to possible soloutions)

11 Oct 2013, 6:07 AM
I made a singleton language class a while ago: https://github.com/4rg0n/poe_orb_calc/tree/master/js/ext/app/library/language

I (https://github.com/4rg0n/poe_orb_calc/blob/master/js/ext/app/library/language/Language.js)t uses a xml file for the translations:

It can be easily used in any project by calling

MyApp.Language.translate('String to translate');

It also supports simple template stuff:

MyApp.Language.translate('Hello my name is {0}', ['Foo']);


MyApp.Language.translate('Hello my name is {name}', {name: 'Foo'});

It also can set the current language as cookie or it will try to read the browser settings. It is not the best, but maybe it helps =D