-
13 Mar 2012 2:59 AM #1
Question about LOCALIZATION
Question about LOCALIZATION
Hi,I have to create an application that has to be localized in English and Italian.
I have find the way to link the locale file "ext-4.0.7-gpl/locale/ext-lang-it.js" in the index.html of my app.
This solve the problem of localize the default of the Ext framework.
My problem is : How can I localize english string about 'label','button text',or any other components I create in my app???
Could someone give me some ideas???
Thanks a lot and regards.
Grubby
-
13 Mar 2012 3:04 AM #2
Do exactly the same thing. Lets say you have some class:
Create your own app locale file with the appropriate translations.Code:Ext.define('MyClass', { myLabel: 'Foo' });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
13 Mar 2012 3:28 AM #3
Hi evant!Thanks for the answer!
I have tried this :
In my app I define a new class extended window and setting a title in english.
After in the ext locale file I add :Code:Ext.define('ConfMailWindow', { extend: 'Ext.window.Window', title: 'SIMULATION', });
and linking the locale in index.html all is ok!!!Code:if(ConfMailWindow){ Ext.apply(ConfMailWindow.prototype, { title : "SIMULAZIONE" }); }
BUT!!!
If I want to add items components in my window or any buttons with text and labels...how can I write the code in the class and in the locale file?
Let me say that ,after create my class (my FIRST define class..... sorry but I am new here),I create the object in the app and add inside all the components and buttons ,like this:
Code:Ext.create('ConfMailWindow',{ //title: 'SIMULAZIONE', id: 'simulazione', height: 200, width: 300, layout: 'absolute', modal: true, items: [{ xtype: 'label', x: 10, y: 10, //html: obj.data3 html: message },{ xtype: 'checkbox', //check per mail di conferma registrazione boxLabel: 'Mail', id: 'checkmail', x: 10, y: 80 }], buttons: [{ //text: 'OK', handler: function(){ var details = new Object; details.Mail = E ............ ...... ....
Thnaks a lot!!!!
Grubby
-
13 Mar 2012 3:38 AM #4
You can't do it quite like that.
Instead:
Code:Ext.define('MyClass', { myLabel: 'Foo', initComponent: function(){ this.buttons = [{ text: this.myLabel }]; // other stuff this.callParent(); } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
13 Mar 2012 4:54 AM #5
This is very cool!!!
Now I will try to app this code!
And a last question...
If I want to pass a variable inside the new created object ,how can i write the code?
This is my first code and if I want to have the variable 'message' inside the window,how can I write in the definition class???Code:Ext.create('ConfMailWindow',{ //title: 'SIMULAZIONE', id: 'simulazione', height: 200, width: 300, layout: 'absolute', modal: true, items: [{ xtype: 'label', x: 10, y: 10, //html: obj.data3 html: message },{
Because the 'message' is created after ,doing an AJAX request and using a Json object from the php server...
Thanks evant!!!
-
13 Mar 2012 6:33 AM #6
Now,I think I have resolved my problem,but I wish you/someone other look at my code and tell me if I have done in a right way.
This is my code:
Doing in this way,I can pass troght a function (confMail) the variables that after I use to initialize my object ConfMailWindow.Code://definizione window class x mail di conferma Ext.define('ConfMailWindow', { extend: 'Ext.window.Window', //Inizializzazione properties di default in inglese title: 'SIMULATION', myButtonText: 'OK', myBoxLabel: 'Mail', myMessage: '', myIdUser: 0, id: 'simulazione', height: 200, width: 300, layout: 'absolute', modal: true, //Inizializzazione componenti initComponent: function(){ this.items = [{ xtype: 'label', x: 10, y: 10, html: this.myMessage //html: this.myIdUser },{ xtype: 'checkbox', //check per mail di conferma registrazione boxLabel: this.myBoxLabel, id: 'checkmail', x: 10, y: 80 }]; this.buttons = [{ text: this.myButtonText, myButIdUser: this.myIdUser, handler: function(){ var details = new Object; details.Mail = Ext.getCmp('checkmail').getValue(); details.Iuser = this.myButIdUser; Ext.Ajax.request({ url: '../mail_registration.php', params: {data: Ext.encode(details)}, success: function(response, opts) { Ext.getCmp('simulazione').close(); var obj = Ext.decode(response.responseText); Ext.Msg.alert('ATTENZIONE', obj.data1, function(){ Ext.getCmp('login').getForm().reset(); }); } }); } }]; // other stuff this.callParent(); } }); //Funzione di simulazione mail di conferma confMail = function(message, idUser){ Ext.create('ConfMailWindow',{ myMessage: message, myIdUser: idUser }).show(); }
Is it correct to write in this way to have the right value???
..or there is another right way???Code:this.buttons = [{ text: this.myButtonText, myButIdUser: this.myIdUser, handler: function(){ var details = new Object; details.Mail = Ext.getCmp('checkmail').getValue(); details.Iuser = this.myButIdUser;
Thanks a lot!!!
Bye Grubby


Reply With Quote