-
4 Jul 2012 12:51 AM #31
Hi Mitchell,
I'm coming across a similar issues where DataViews/Templated components need to be refreshed (where there are string literals inside) and Stores regenerated which requires a little more specific logic than the standard component properties do for updating.
I like the idea of an event being fired which these troublesome components can listen to it and do what they need to.
Another option might be to allow a function to be passed in the locales config which would get executed in the scope of the component when the locale is changed and this logic can reside there.
Anyways, I'll try and report back on what I end up doing and seeing what works best.
Thanks for your work on this - it certainly takes the pain out of localising apps!
StuartSwarmOnline.com - Web & Mobile Development and Training Services
Check out our Ext JS 4 Cookbook
...and the FREE e-book Ext JS 4 Cookbook - Exploring Further filled with recipes that we couldn't fit in!
@StuartAshworth9
@SwarmOnline
-
6 Jul 2012 6:17 AM #32
I spent a couple of days trying to get the DataView/Item done but just couldn't get it sorted properly.
In the end I just did this inside DataView override:
It changes the original content so you can't translate it back/again... but I'm going to have to move onto more important things for now.Code:setLocale : function(locale) { var me = this, locales = me.locales || me.getInitialConfig().locales, manager = me.locale, store = me.getStore(); store.each(function (data) { var text = defaultText = data.get('text'); data.set('text', manager.get(text, defaultText)); }); me.callOverridden(arguments); },
I tried overriding prepareData() but it's called before the item get's the locale manager stuck to it so it's too early to do it for me.
Also: I was talking about having a default locale that doesn't need translations. In the end I just made the defaultText the original text that get's passed into the translation tool so you don't need english translations and if the text hasn't been done then it will display english anyway... better in english than in nothing.
-
10 Jul 2012 12:53 AM #33
Hi everyone,
First, I want to thank Mitchell for this great plugin...
Now, I have a newbie question, how can I use the plugin to translate my defaultBackButtonText and the loadingText properties?
-
25 Jul 2012 3:22 PM #34
Just looking at translating the Title within NavigationView/Bar and it's peppered all over the code.
Looks like it's going to require quite a bit of know-how to edit this one and I bet it changes massively in the next release.
Edit: I decided to kill all NavigationView/Bar's in my application as I feel they're annoying for adding Back Button as well. I think you either use the NV/Bar for your entire application or not at all...
-
28 Jul 2012 2:37 PM #35
So that my translation files are smaller and alot of my application pulls in translated data/information from the server my API calls are something like:
/en/get-events
/de/get-events
To do this, for all of my proxy, ajax calls I do: /{locale}/get-events
And this code to replace the {locale} variable:
Code:Ext.define('Ux.data.Connection', { requires: [ 'Ext.data.Connection', ] }, function() { Ext.override(Ext.data.Connection, { request: function (options) { var locale = 'en'; if (Ux.locale.Manager.getLanguage()) { locale = Ux.locale.Manager.getLanguage(); } options.url = options.url.replace('{locale}', locale); this.callParent(arguments); } }); });
-
30 Jul 2012 1:42 PM #36
Had to translate selectfields. As you can't set a locales: {} with everything in there (doesn't really make sense). I removed all the placeholder stuff as I'm not really using it (strings default to EN for me). It's easy looking at the others to add it back. I see that if you translate a label on the selectfield as well then setLocale gets called twice on the same component, which I guess need to be merged somehow.
Basically, upon setLocale it sets the _originalString field to the store to hold the displayField so that when you change the locale again, it will still know the original string.
Also, at least have a locales: {} set on the dropdown
Code:Ext.define('Ux.locale.override.st.field.Select', { override : 'Ext.field.Select', requires : [ 'Ux.locale.override.st.Component' ], setLocale: function(locale) { // TODO: Merge this and Ux.locale.override.st.field.Field as they're both running the same function? var me = this, locales = me.locales || me.getInitialConfig().locales, manager = me.locale, displayField = me.getDisplayField(), label = locales.label, store = me.getStore(), fields; // Translate the label if set if (label) { if (Ext.isObject(label)) { label = label.key; } label = manager.get(label); if (Ext.isString(label)) { me.setLabel(label); } } // There's a store as well, translate stuff if (!store) { return; } fields = store.getFields(); if (manager && fields) { // Allow saving original value for re-translation later fields.push("_originalString"); store.setFields(fields); store.each(function (record) { if (record.get('_originalString') === undefined) { record.set('_originalString', record.get(displayField)); } record.set( displayField, manager.get(record.get('_originalString')) ); }); me.updateStore(store); } } });
-
4 Sep 2012 12:21 PM #37
Hi Mitchell... i´m trying to put your component on my app, but nothing key is loaded from .json... my code:
partial code from my viewCode:Ext.Loader.setConfig({ enabled : true, paths : { Ux : 'Ux' } }); Ext.application({ name: 'selfservice', bundle: '', requires: [ 'Ext.Ajax', 'Ext.MessageBox', 'Ext.i18n.Bundle', 'Ux.locale.Manager', 'Ux.locale.Manager', 'Ux.locale.override.st.Component', 'Ux.locale.override.st.Button', 'Ux.locale.override.st.Container', 'Ux.locale.override.st.TitleBar', 'Ux.locale.override.st.field.Field', 'Ux.locale.override.st.field.DatePicker', 'Ux.locale.override.st.picker.Picker', 'Ux.locale.override.st.picker.Date' ], models: ["User"], stores: ["Users"], controllers: ["Users"], views: ["AuthenticateForm"], icon: { '57': 'resources/icons/Icon.png', '72': 'resources/icons/Icon~ipad.png', '114': 'resources/icons/Icon@2x.png', '144': 'resources/icons/Icon~ipad@2x.png' }, isIconPrecomposed: true, startupImage: { '320x460': 'resources/startup/320x460.jpg', '640x920': 'resources/startup/640x920.png', '768x1004': 'resources/startup/768x1004.png', '748x1024': 'resources/startup/748x1024.png', '1536x2008': 'resources/startup/1536x2008.png', '1496x2048': 'resources/startup/1496x2048.png' }, launch: function() { // Destroy the #appLoadingIndicator element Ext.fly('appLoadingIndicator').destroy(); var userLang = (navigator.language) ? navigator.language : navigator.userLanguage; Ux.locale.Manager.setConfig({ ajaxConfig : { method : 'GET' }, language : 'en', tpl : 'resources/{locale}.json', type : 'ajax' }); Ux.locale.Manager.init(); Ext.i18n.Bundle.configure({ bundle: 'SelfService', language: userLang, path: 'resources', noCache: false }); var authenticateForm = { xtype: "authenticateform" }; // Initialize the main view Ext.Viewport.add([authenticateForm]); }, onUpdated: function() { Ext.Msg.confirm( "Application Update", "This application has just successfully been updated to the latest version. Reload now?", function(buttonId) { if (buttonId === 'yes') { window.location.reload(); } } ); } });
Tks for your helpCode:Ext.define('selfservice.view.AuthenticateForm', { extend: 'Ext.form.FormPanel', alias: "widget.authenticateform", config: { fullscreen: true, scrollable: 'vertical' }, initialize: function() { var titlebar, buttonbar, authenticateButton, fields; titlebar = { id: 'authenticateFormTitlebar', xtype: 'toolbar', locales : { title : 'toolbar.all.upTitle' } };
George
-
10 Sep 2012 12:32 PM #38
yeeeee
some support for SA2 (extjs 4.1.1) ?????????????????????????????????
-
10 Sep 2012 12:34 PM #39Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
11 Sep 2012 4:04 AM #40
Yes. Is it possible to integrate sencha extjs Architect 2 for 4.1.1?



Reply With Quote