In my application, the headings / texts of all the divisions are transferred based on the loaded store before the application launch. In the application, I have a button that changes the store URL and reloads the store to switch the language. The problem is that all classes are already loaded, so the components are provided with the previous locale. Here's the button's code:
tbar: [{xtype: 'button', id: 'btn-test', text: 'xxx', handler: function () {lang = 'n '; I18n.getBundlestore (). Load ({url: '/ GSIP / Resources / GSIIP / IILN / Bundle-' + Lang + '. Properties'}); // Weave = Ext.create ('I18N.ResourceBundle'); . Ext.getCmp ('mainview') deleted (); Extension ('Ext.container.Viewport', {id: 'mainview', layout: 'border', item: [{xtype: 'gsip_mainpanel', area: 'center', item: [{xtype: 'gsip_categoriestabpanel'}] }] The exact same viewpoint is in my application.js.Lang and i18n are global variables.The old viewport is destroyed and new but has been reloaded
handler: function () {lang = 'en';} Ext.get Delete ('menuview'). (I18n.getBundlestore). Load ({url: '/ gsip / resource / gsip / iiiln / bundle-' + lang + '. Properties', callback: function () {Ext.create ('Ext.container' Vivport ', {id:' mainview ', layout:' border ', item: [{xtype:' gsip_mainpanel ', area:' center ', item: [{xtype:' gsip_categoriestabpanel '}}}]}}}}}};} Categories tabanel:
Ext.define (' GSIP.view.CategoriesTabPanel ', {extension ('Key-1')}, {}: 'Ext1ab.Panel', nickname: 'widget.gsip_categoriestbpanel', layout: 'fit', items: [[Xtype: 'gsip_planytabpanel', title: i18n.getMsg ('key-1')}, {xtype: 'Gsip_adresytabpanel', Title: i18n.getMsg ('key-2')}], ini TComponent: function () {this.callParent (argument); } });
and ResourceBundle (i18n variable is an example of this class):
Ext.define ('I18N.ResourceModel', expand: 'Ext.data.Model' , Field: ['key', 'value']}); Extension. ('I18N.ResourceStore', 'Expand:' GSIP Cor. Registered Store ', Model:' I18N.ResourceModel ', Auto Load: Correct, Proxy: {Type:' Ajax ', URL:' / GSIIP / Resource / Gsip / i18n / bundle- '+ lang +'. Properties', Reader: {type: 'Jason', root: 'PL', Success Property: 'Success'}}}); Ext.define ('I18N.ResourceBundle', {config: {bundlestore: Ext.create ('I18N.ResourceStore')}}, constructor: function (configuration) {this.initConfig (config); return it;}, getMsg: Get the function (key) {return.bundlestore.getAt (this.bundlestore.findExact ('key', key)) ('value');}}, function () {// callback function, called before store load Within the definition of: (});
You can specify the item as a configuration Setting it means that it always supports the same object (And will not be updated). As the first step, you should move the item definition to the initComponent, where you can also do it console.log (i18n) to correct it.
Comments
Post a Comment