elettronik
6 Nov 2012, 11:49 PM
Hi, I'm porting a project from Extjs3 to extjs4. In ext3 we have translation managed by an override on the component class, so I've used the same approach on the new project.
My override look like this:
Ext.define('Project.localization.ComponentLocalization',{
override: 'Ext.Component',
listeners: {
/**
* Beforerender event used to translate labels of component
*/
beforerender: function(component, eOpts){
component.translate();
}
},
translate: function() {
....
}
});
The code above works only for the top level component I create with Ext.create, but the event is never fired for the children. If I have a panel like this:
Ext.define('MyPanel', {
extend: 'Ext.form.Panel',
title:'panel.title',
items: [{
xtype: textfield,
fieldlabel: 'label.text'
}]
})
I got correctly translated the title of the panel but there is no call to translate on the child textfield. My questions are:
The beforeRender event is called only for top level element and I should do some recursive children managment?
Is there another event I could hook to make this behavior?
The temporary solution I found is to make a call to translate on the override of constructor, but I think is not the best way.
My override look like this:
Ext.define('Project.localization.ComponentLocalization',{
override: 'Ext.Component',
listeners: {
/**
* Beforerender event used to translate labels of component
*/
beforerender: function(component, eOpts){
component.translate();
}
},
translate: function() {
....
}
});
The code above works only for the top level component I create with Ext.create, but the event is never fired for the children. If I have a panel like this:
Ext.define('MyPanel', {
extend: 'Ext.form.Panel',
title:'panel.title',
items: [{
xtype: textfield,
fieldlabel: 'label.text'
}]
})
I got correctly translated the title of the panel but there is no call to translate on the child textfield. My questions are:
The beforeRender event is called only for top level element and I should do some recursive children managment?
Is there another event I could hook to make this behavior?
The temporary solution I found is to make a call to translate on the override of constructor, but I think is not the best way.