PDA

View Full Version : Best way of implementing Internationalization for a Huge Enterprise Application



AkshayKalbhor
24 Jun 2014, 6:50 AM
Hello,

I am trying to do the internationalization for a huge Enterprise Application which contains above 1000 screens.

I have been through the standard approach specified in
http://dev.sencha.com/deploy/ext-4.0.0/examples/locale/dutch-form.html

I want to know if there is any other out of the box solution to support internationalization.

Please help..

Gary Schlosberg
30 Jun 2014, 7:04 AM
The localization example you included is the out of the box solution. Here's a more recent version:
http://docs.sencha.com/extjs/4.2.1/#!/example/locale/dutch-form.html

Besides the need to support large numbers of screens, what are your requirements?

AkshayKalbhor
1 Jul 2014, 1:10 AM
I had created files like en.js, ja.js, es.js etc, Each file had globals as

en.js


TRANSLATIONS = {
SAVE: 'Save',
CANCEL: 'Cancel'
}


ja.js


TRANSLATIONS = {
SAVE: '??',
CANCEL: '????'
}


I was loading these files from index.html, and using the keys for getting the translations wherever required.

eg:


{
xtype: 'button',
text: TRANSLATIONS.SAVE,
itemId: 'saveButtonId',
buttonAlign: 'right',
ui: 'CustomBtnSubmit',
scale: CONSTANTS.BUTTONSIZE,
formBind : true
}


This approach worked fine until preparing a production build with sencha cmd, where sencha cmd removes all the files from index.html, and also does not accept globals like TRANSLATIONS as used above.

So I am changing the Translation files to Singleton Files as

en.js


Ext.define("Academia.translations.commonTranslations", {
singleton : true,


SUBMIT: 'Submit',
RESET: 'Reset',
DELETE: 'Delete',
SAVE: 'Save',
CANCEL: 'Cancel',

/**
* method to get translations for Common Translation.
* @param {String} key that should be translated.
* @returns {String} the translation for the passed key.
* @author Akshay.Kalbhor
*/
getCommonTranslation: function(key) {
var translation = Academia.translations.commonTranslations[key];
if(translation == null || translation == undefined || translation == '') {
translation = key;
}
return translation;
}


});


and now using the translations as below.


{
xtype: 'button',
text: Academia.translations.commonTranslations.getCommonTranslation('SAVE'),
action: 'submit',
formBind: true,
action: 'Submit',
ui: 'CustomBtnSubmit',
scale: Academia.constants.CommonConstants.getCommonConstants('BUTTONSIZE'),
itemId: 'statAccSaveButton'

}


In short I am trying to create a single translation file which acts like a resource bundle providing all the translations..
But facing issues in the above method as Sencha CMD build does not recognize the Global variables.