PDA

View Full Version : Ux.locale.Manager



mitchellsimoens
27 Dec 2011, 12:53 PM
Need to handle dynamic locale? Want to load locale via Ajax? Want locale to be applied without rerendering components? If so, Ux.locale.Manager may suit your needs.

This manager does not support all components but examples have been provided to support other subclasses of Ext.Component (Sencha Touch or custom component).

This manager also works with Ext JS 4, one class to rule them all!

Sencha Market Listing: http://market.sencha.com/addon/ux.locale.manager
GitHub repo: https://github.com/mitchellsimoens/Ux.locale.Manager

mitchellsimoens
27 Dec 2011, 12:54 PM
I will be supporting JsonP in the next release.

This does not use bundles, no need for them really.

semiaddict
29 Dec 2011, 3:54 AM
Thank you mitchellsimoens; exactly what I was looking for !

semiaddict
29 Dec 2011, 4:32 AM
I've slightly modified Ux.locale.override.st.Container to allow specifying a title on a non tabbed container.

The patch is attached.
I've also submitted a pull request (https://github.com/mitchellsimoens/Ux.locale.Manager/pull/1) on GitHub.

semiaddict
12 Jan 2012, 3:54 AM
@mitchellsimoens,

Any ideas on how to get this working for an Ext.MessageBox ?
Since they are created on the fly, the setLocale function isn't called by the manager.

Thank you.

mitchellsimoens
12 Jan 2012, 5:40 AM
The buttons are already created and MessageBox should be picked up if you put a setLocale method so you would have to dig down to the buttons to change them.

dishwashwebdesign
4 Apr 2012, 1:31 PM
That language switch is working smooth so far, thanks for providing.
What do i have to be aware of when doing a productive build?
Just copying the Ux & locales folder into the build/production doesn't seem to do the trick :)
In app. js I added:


Ext.Loader.setPath({
'Ext': 'sdk/src',
'Ux' : 'Ux'
});

The error console of the production app says only this with a blank app screen:


index.html:65Error evaluating file:///Users/macbook/myapp/build/production/app.js with message: SyntaxError: Unexpected token ':'


However, if i build the app without the "Ux" : "Ux" loader config, the app loads fine, just without any Ux support and this error console message:


TypeError: 'null' is not an object (evaluating 'a.title')


thanks for any hints...

mitchellsimoens
5 Apr 2012, 4:37 AM
All you should have to do is create the path and then require it via Ext.require. When you do a build it should see this require and include it in the build.

dishwashwebdesign
5 Apr 2012, 6:17 AM
hmmm,
you mean in the app.js under ext.define in the requires: ([]) section? well, i already did that, but no luck.
do i have to include all the classes of ux.locale or just ux.locale.Manager?
the Ux folder is in the index.html root directory. So there should not be a need to specify its path, should it?
thanks heaps & happy easter bunnies

mitchellsimoens
5 Apr 2012, 6:21 AM
Look at the example. It sets a path and uses Ext.require to require the classes.

dishwashwebdesign
5 Apr 2012, 6:34 AM
yup, did include all the loading and requiring settings. i slightly had to change the Ux.locale.Manager.setConfig({ and Ux.locale.Manager.init section:
this is my app.js:


Ext.Loader.setConfig({
enabled : true,
paths : {
Ux : 'Ux',
'Ext': 'sdk/src'
}
});


Ext.application({
name: 'myeasterapp',


requires: [
'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'
],


views: [
'Main',
'Contact',
'Status',
'Settings'
],


models: [
'Contact',
'Status'
],


stores: [
'Contacts',
'Status'
],

phoneStartupScreen: 'resources/loading/Homescreen.jpg',
tabletStartupScreen: 'resources/loading/Homescreen~ipad.jpg',


launch: function() {


// Initialize the main view
Ext.Viewport.add(Ext.create('myeasterapp.view.Main'));



Ux.locale.Manager.setConfig({
ajaxConfig : {
method : 'GET'
},
language : 'de',
tpl : 'locales/{locale}.json',


type : 'ajax'
});
Ux.locale.Manager.init();

}
});




well, in dev mode this works just fine like that...

dishwashwebdesign
9 Apr 2012, 10:11 AM
is there a need to change the init and setConfig section?
well, i tried changing it, but the production biuld still doesnt work afterwards...
any further hints?

dishwashwebdesign
10 Apr 2012, 12:43 AM
i took the ux.locale.manager complete example and built it pretty much unchanged into a production version.
same error there in the console:


app.js:1 (file:///Users/macbook/Documents/dishwashwebdesign/swisscommobile/multilanguage/mitchellsimoens-Ux.locale.Manager-c353d36/st/build/production/app.js)
TypeError: 'null' is not an object (evaluating 'a.title')

where app.js is an exact copy of example index.js.


it would be great if there is a way to get this language switch working in a productive built.
thanks heaps

mitchellsimoens
10 Apr 2012, 5:46 AM
@dishwashwebdesign I just pushed an update that includes an MVC example that you can use Sencha Command to build a production.

So if you go to st/mvc/ and run this:


sencha app build production

It should build fine (did on my OSX 10.7) and when you launch the functionality should work with no issues.

dishwashwebdesign
11 Apr 2012, 7:08 AM
Mitchell, you are a legend. thanks heaps. it works smoothly like a swiss army knife :)

mitchellsimoens
11 Apr 2012, 8:50 AM
Mitchell, you are a legend. thanks heaps. it works smoothly like a swiss army knife :)

Fantastic! I did have to patch the overrides to get the locale for the build so there was a bug. Haven't looked into it much why the behavior changes but hope to have some time to do so soon. I had to get the locales from the initialConfig in the production version.

9tailfox
15 Apr 2012, 7:43 PM
Hi Mitchell,

im kidda new with sencha..is there any example for selectfields options usage?

mitchellsimoens
16 Apr 2012, 3:40 AM
Check out the example that comes with the Ux.local.Manager. All fields the placeHolder and label can be changed. The values in the selectfield are not handled as if you are using a store then it will display what the server returned.

intellix
30 Apr 2012, 12:42 AM
I'm not entirely sure how this is supposed to be implemented with Architect 2...
If I import all of the JS files then I need to add a listener for painted to do the replacing of locale text right?

Architect is winding me up massively, feels like I'm stuck inside a bubble of limitations

dishwashwebdesign
6 Jun 2012, 5:01 PM
Hello,

another little concern i pumped into:
is type->jsonp supported in this release?

i got errors when building a productive built:


Ux.locale.Manager.setConfig({
ajaxConfig : {
method : 'GET'
},
language : currentLanguage,
type: : "jsonp",
tpl : '/locales/{locale}',
});

errors:


[INFO] Minifying resources/css/app.css
[ERROR] Error: Command failed:
[ERROR] 86:25:syntax error


[ERROR] 87:25:syntax error


[ERROR] 88:10:syntax error


[ERROR] 1:0:Compilation produced 3 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 3 syntax errors.
at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:154)
at org.mozilla.javascript.Parser.parse(Parser.java:392)
at org.mozilla.javascript.Parser.parse(Parser.java:337)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:312)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:533)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
[ERROR]

any idea?

thanks heaps...

pepperseb
11 Jul 2012, 1:49 AM
Hey,

How can I use the plugin to translate my defaultBackButtonText and the loadingText properties?

barts83
13 Sep 2012, 12:50 AM
hi, great plugin Mitchell,
is there example of how to use Ux.locale.Manager locales with Ext.Msg.alert, Ext.XTemplate ?

semiaddict
13 Sep 2012, 7:21 AM
Since an alert is created on the fly, I believe the easiest way to have the title and message translated would be to get the values directly from the Locale Manager as so:

Ext.Msg.alert( Ux.locale.Manager.get('alerts.one.title', 'Your default title here'),
Ux.locale.Manager.get('alerts.one.message', 'Your default message here'),
Ext.emptyFn
);

Here's the locale json file that would work for the above example:

{ "alerts" : {
"one" : {
"title" : "This is my first alert",
"message" : "The alert's message"
}
}
}

tangix
25 Oct 2012, 7:37 AM
OK, maybe I am doing a complete fool of myself here, but I have to ask after spending an afternoon troubleshooting Ux.locale;
is Ux.locale compatible with ST 2.1.0-RC2? I have problems localizing my application after moving from 2.0.1.1 to 2.1.0-RC2 and the root cause seems to be that buttons are no longer Ext.Buttons, instead Ext.getClassName() reports them as Ext.Component and then the override(s) fail badly for buttons etc.

Is this just me...?

Love the extension and it has really made my day! Thanks,
/Mattias

intellix
25 Oct 2012, 7:50 AM
Fool you not be. I am also having issues with RC2. Button text does not appear. It works in RC1 though

tangix
25 Oct 2012, 8:36 AM
Interesting to change this (in my eyes "break this") so late in the release process...

mitchellsimoens
25 Oct 2012, 11:37 AM
The button override wasn't hitting the override for the Component. I have pushed some updates to get this to work but the mvc app isn't building properly so I am working on that to get it to build just fine.

mitchellsimoens
25 Oct 2012, 11:48 AM
Ok, figured out the issue and pushed an update. Also removed some trailing commas, don't know who's PR did that, I usually deny the merge if I see them.

tangix
29 Oct 2012, 2:38 AM
Ok, figured out the issue and pushed an update. Also removed some trailing commas, don't know who's PR did that, I usually deny the merge if I see them.
Thanks Mitchell,
now working as expected with 2.1.0-RC2.
2.1.0 is really needed on low-end Android phones to get any kind of performance with ST. 2.0.1.1 is dog slow on my Sony Xperia but 2.1.0 is ... "fast and fluid" :))

Cheers,
/Mattias

tangix
29 Oct 2012, 3:14 AM
OK - found another problem with 2.1.0-RC2. Labels are no longer set correctly on fields. Added a constructor to override/st/field/Field.js to fix it:

constructor : function() {
this.callSuper(arguments);
},

couetbis
15 Nov 2012, 2:38 AM
Hi,
This extension works with microloader in ST 2 (2.0 or 2.1) ?
Thanks

mitchellsimoens
18 Nov 2012, 6:32 AM
Works in my tests

fuchsi
13 Dec 2012, 4:40 AM
Hi!

I'm using the really great Ux.locale.Manager in my Sencha Touch 2.1 application. Now I'm wondering if it is possible to pass an default language to the Manager when the language has no available json-file.

Is it possible in the current Version of the locale.Manager or what can I do to pass an default language for my app?

Thank You!

mitchellsimoens
13 Dec 2012, 5:39 AM
You should keep a list of available locales and set one of them as the language if the language of the browser is not one of them.

fuchsi
13 Dec 2012, 7:14 AM
Thank you for your hint.
It works! :)

couetbis
2 Jan 2013, 2:26 AM
Hi,
It's a good extension, thanks.
How can I use it to translate data in a store ?

With microloader, content is already loaded (so isn't available yet), my code :


Ext.define('MyApp.store.Menus',{
extend: 'Ext.data.Store',
config:{
model : 'MyApp.model.Menu',
data: [
{'id':1,'titre':Ux.locale.Manager.get('labels.menustore_volumes'),'action':'volumes'},
{'id':2,'titre':Ux.locale.Manager.get('labels.menustore_conversions'),'action':'conversions'},
{'id':3,'titre':Ux.locale.Manager.get('labels.menustore_articles'),'action':'articles'},
{'id':4,'titre':Ux.locale.Manager.get('labels.menustore_publications'),'action':'publications'},
{'id':5,'titre':Ux.locale.Manager.get('labels.menustore_apropos'),'action':'apropos'}
]
}
});

What must I do ?

couetbis
28 Jan 2013, 12:55 AM
Any idea for previous post ?

couetbis
15 Feb 2013, 2:54 AM
Another question : how can we do with templates ?


{
xtype : 'dataview',
store : 'ConversionsEquivalence',
itemTpl : [
'<div class="statm-title">' + Ux.locale.Manager.get('labels.conversions_equivalence_statm_titre')+'</div>',
'<tpl for="statistiquesMondiales">',
'<div class="statm"> ',
...
].join('')
}

This, returns "undefined"

couetbis
19 Feb 2013, 12:06 AM
I found a solution for templates :


{
xtype : 'dataview',
store : 'ConversionsEquivalence',
itemTpl : new Ext.XTemplate([
'<tpl for="conversionsSimples">',
...
'<div class="statf-title">{[this.getTraduction(\'labels.conversions_equivalence_statf_titre\')]}'
+ '&nbsp;</div><div class="statf-desc">{[this.getTraduction(\'labels.conversions_equivalence_statf_desc\')]}</div>',
...
'</tpl>',
'</div> ','</tpl>' ].join(''),{
getTraduction: function(cle){
return Ux.locale.Manager.get(cle);
}
}

For data in store I do this :


Ext.define('Cpdp.model.Menu', {
extend: 'Ext.data.Model',
config:{
fields: [
{name: "id", type: "int"},
{name: "codeTitre", type: "string"},
{
name: 'titre',
convert: function(value, record) {
return Ux.locale.Manager.get(record.get('codeTitre'));
}
},
{name: "action", type: "string"}
]
}
});

Ext.define('Cpdp.store.Menus',{
extend: 'Ext.data.Store',
config:{
model : 'Cpdp.model.Menu',
autoLoad: false,
proxy:{
type: 'ajax',
url: 'locales/menu.json'
}
}
});

urmilsetia
19 Feb 2013, 4:47 AM
Hi mitchellsimoens, Really nice extension.

I have just one question, I am making an app for iOS and Android now when user changes the locale of the iOS device(from settings), does it automatically get the locale from the OS or I have get it to sencha layer and update it?

urmilsetia
19 Feb 2013, 5:15 AM
Hi mitchellsimoens, Really nice extension.

I have just one question, I am making an app for iOS and Android now when user changes the locale of the iOS device(from settings), does it automatically get the locale from the OS or I have get it to sencha layer and update it?

Or should I, on application launch find the language using ?window.navigator.language and based on that decide the locale

armode
19 Feb 2013, 11:00 PM
I think this is all up to you.

In my case, there is a default language for the first launch, which is set in a server config file. After that the user is able to change the language in app settings and this is stored in HTML5 local storage.

But as I wrote, this is all up to you. Locale Manager just gives you the possibility to override almost all touch components and get a language file via ajax.

Have a look into the example (https://github.com/mitchellsimoens/Ux.locale.Manager/tree/master/st)on github; it's in the "st" folder...

mitchellsimoens
20 Feb 2013, 7:17 AM
Just posting a link to a blog post that does a really good job at describing how to use this: http://www.swarmonline.com/2013/02/localising-sencha-touch-and-ext-js-applications-with-ux-locale-manager/

arael78
12 Mar 2013, 8:00 AM
Ext.define("USIMobile.view.Calendar", { extend: 'Ext.dataview.List',
xtype: 'calendar',


config: {
id: 'calendar',
locale: {
title: 'title.calendar',
},
emptyText: 'No info available.',
itemTpl: '{[values.id != "academiccalendar" ? values.title : values.title + USIMobile.Session.getAcademicCalendarStore().first().get("year")]}',
},
});


How do I fix the code to make it work with components not included in the Ux/locale/override/st directory?

In this case I'm not able to set the title according to the lang.json definitions. Should I add Ux.local.override.st.DataView and Ux.local.override.st.List classes?

What would be the best approach to include the support for List component and for all other components I extend?

Thank you very much.

arael78
13 Mar 2013, 5:53 AM
How do I set a locale for the Panel title?

mitchellsimoens
13 Mar 2013, 5:58 AM
How do I set a locale for the Panel title?

Sencha Touch Panels don't have a title.

arael78
13 Mar 2013, 6:09 AM
You are right indeed.

But I don't understand. If I extend the Ext.form.Panel or Ext.dataview.List and set the title in the config object it is displayed correctly. I use Navigation view to navigate between various views. Where is then set the title and is there a way to use Ux.locale.Manager in this case?

Here is a the code:



Ext.define("USIMobile.view.Courses", { extend: 'Ext.dataview.List',
xtype: 'courses',


config: {
id: 'courses',
title: 'Courses',
emptyText: 'No courses found.',
itemTpl: '{title}',
grouped: true
}
});




This is the controller function that displays the view above:



listCourses: function() {
this.filterCoursesStore();
if(typeof this.getCourses() == 'object') {
this.getCourses().refresh();
this.getCourses().setTitle(Ux.locale.Manager.get('title.courses'));
this.getHome().push(this.getCourses());
} else {
this.getHome().push({
xtype: 'courses',
title: Ux.locale.Manager.get('title.courses'),
store: USIMobile.Session.getCoursesStore()
});
}
},


So this doesn't work: this.getCourses().setTitle(Ux.locale.Manager.get('title.courses'));
because the Ext.dataview.List doesn't have setTitle.

But pushing the new object in the navigationview sets the title.

mitchellsimoens
13 Mar 2013, 6:10 AM
That's because the navigation view uses it (same for tab panel) but the panel, form panel, list, etc do not use it. So if you want the dynamic updating of titles in a navigation view you will have to work with both the panel and the navigation view.

arael78
13 Mar 2013, 6:23 AM
So this means that I should overwrite the Ext.Navigation.view and get it to read the locales object from the panel or list that is visible?

nbourdeau
14 Mar 2013, 8:42 AM
So this means that I should overwrite the Ext.Navigation.view and get it to read the locales object from the panel or list that is visible?

Hi, same need here! Did you found out how to override to get this working ?
@Mitchell can you provide some starting point on how to do this?

thanks

arael78
15 Mar 2013, 5:24 AM
When I use the Ux.locale.Manager with datepickerfield it doesn't show up and raises an error on the first click. On the second click everything works, the months are translated.

Here is the code:


Ext.define("USIMobile.view.SearchSportActivity", {
extend: 'Ext.form.Panel',
xtype: 'searchsportactivityform',
fullscreen: true,

requires: [
'Ext.TitleBar',
'Ext.form.FieldSet',
'Ext.field.Text',
'Ext.field.Select',
'Ext.picker.Date',
'Ext.field.DatePicker',
],


config: {
id: 'searchsportactivityform',
items: [
{
xtype: 'fieldset',
items: [
{
xtype: 'textfield',
name: 'name',
locales: {
label: 'label.name'
}
},
{
xtype: 'selectfield',
name: 'category',
locales: {
label: 'SelectFieldCategory.label',
options: 'SelectFieldCategory.options'
},
usePicker: false,

},
{
xtype: 'datepickerfield',
name: 'from',
locales: {
label: 'label.from',
},
dateFormat: 'd M Y',
picker : {
enableLocale : true,
locales : {
months : 'months'
},
yearFrom: 2013,
},
},
{
xtype: 'datepickerfield',
name: 'to',
locales: {
label: 'label.to',
},
dateFormat: 'd M Y',
picker : {
enableLocale : true,
locales : {
months : 'months'
},
yearFrom: 2013,
},
},
{
xtype: 'button',
locales: {
text: 'button.search',
},
ui: 'confirm',
action: 'search',
}


]
}
]
},
}

This is the error:


Uncaught TypeError: Cannot set property 'innerHTML' of undefined Container.js:191
Ext.define.updateListItem Container.js:191
Ext.define.onStoreUpdate DataView.js:1030
Ext.define.doFire Controller.js:199
Ext.define.fire Controller.js:126
Ext.define.doDispatchEvent Dispatcher.js:347
Ext.define.dispatchEvent Dispatcher.js:328
Ext.define.doFireEvent Observable.js:256
Ext.define.fireEvent Observable.js:214
Ext.define.afterEdit Store.js:1348
Ext.define.notifyStores Model.js:1161
Ext.define.afterEdit Model.js:1123
Ext.define.set Model.js:821
(anonymous function) Date.js:26
Ext.define.each Collection.js:523
Ext.define.each Store.js:1244
Ext.define.setLocale Date.js:24
Ext.define.getPicker DatePicker.js:11
Ext.define.onFocus DatePicker.js:357
Ext.define.onMaskTap DatePicker.js:297
Ext.define.doFire Controller.js:199
Ext.define.fire Controller.js:126
Ext.define.doDispatchEvent Dispatcher.js:347
Ext.define.dispatchEvent Dispatcher.js:328
Ext.define.doFireEvent Observable.js:256
Ext.define.fireAction Observable.js:245
Ext.define.onMaskTap Input.js:613
Ext.define.doFire Controller.js:199
Ext.define.fire Controller.js:126
Ext.define.doDispatchEvent Dispatcher.js:347
Ext.define.dispatch Publisher.js:65
Base.implement.callParent sencha-touch.js:4616
Ext.define.dispatch Dom.js:252
Ext.define.doPublish Dom.js:294
Ext.define.publish Dom.js:259
Base.implement.callParent sencha-touch.js:4616
Ext.define.publish TouchGesture.js:225
Ext.define.onRecognized TouchGesture.js:209
Ext.define.fire Recognizer.js:58
Ext.define.onTouchEnd Tap.js:60
Ext.define.invokeRecognizers TouchGesture.js:275
Ext.define.onTouchEnd TouchGesture.js:426
override.processEvent TouchGesture.js:498
Ext.define.onEvent TouchGesture.js:102
Base.implement.callOverridden sencha-touch.js:4734
override.onEvent TouchGesture.js:494
(anonymous function) sencha-touch.js:3182


Any help? Please let me know if you need more info.

armode
18 Mar 2013, 6:13 AM
This is a known issue: https://github.com/mitchellsimoens/Ux.locale.Manager/issues/19

I fixed that and Mitchell merged it today, so the issue could be closed.

Also I extended the translation options of the datepickerfield. Now you can set the slotorder and the slot titles: https://github.com/Odi55555/Ux.locale.Manager/commit/be84f76479d402cb3c6bd2fde6f0c8fc8f5322cf

frankbolviken
5 Jun 2013, 6:25 AM
So this means that I should overwrite the Ext.Navigation.view and get it to read the locales object from the panel or list that is visible?

Did you figure this one out? I created a issue on the Github page, which describes this exact issue.
When using navigation view and adding containers with title, it works when you hardcode it, but not when using locales.

Diego Garcia
23 Jun 2013, 9:01 PM
I've been using this plugin for a while and I think it's worth to say it's great!
Great great work @mitchellsimoens!!

I just wanted to say thanks!!

diablo
4 Jul 2013, 5:30 AM
i subscribe, nice job with the locale manager.
one thing though, is it possible to apply it also to a selectfield?

armode
4 Jul 2013, 6:34 AM
one thing though, is it possible to apply it also to a selectfield?

There was the same question some posts earlier and Mitchell replied:


The values in the selectfield are not handled as if you are using a store then it will display what the server returned.

I don't use a store for my selectfields, thats why I use this override. Not sure if this is perfect, but it works for me ;-)



Ext.define('Ux.locale.override.st.field.Selectfield', {
override: 'Ext.field.Select',

requires: [
'Ux.locale.Manager'
],
setLocale: function(locale) {
var me = this,
manager = me.locale,
options = [],
text = '',
defaultText = '';

me.callParent(arguments);

if(me.config.options && me.config.options[0].locales) {
options = me.config.options;
for(var i = 0; i < options.length; i++) {
text = options[i].locales.text;
if(text) {
text = manager.get(text, defaultText);
if(Ext.isString(text)) {
options[i].text = text;
}
}
}
me.updateOptions(options);
}
}
});


That's how it works for me:



{
xtype: 'selectfield',
locales: {
label: 'fields.respond'
},
options: [{
locales: {
text: 'fields.yes'
},
value: 'J'
}, {
locales: {
text: 'fields.no'
},
value: 'N'
}]
}

arael78
15 Jan 2014, 8:00 AM
I have changed the Ux.locale.Manager to Ext.locale.Manager and copied all the content to touch/src/locale directory.

It works very well when I use the development microloader. But I'm not able to generate the production build.

The sencha app refresh command fails when processing Ext.locale.Manager class.

Here is the log. Please help me. :s



/s/h/t/www git:master ??? sencha app refresh Sencha Cmd v4.0.1.45
[INF]
[INF] init-plugin:
[INF]
[INF] cmd-root-plugin.init-properties:
[INF]
[INF] init-properties:
[INF]
[INF] init-sencha-command:
[INF]
[INF] init:
[INF]
[INF] app-refresh:
[INF] [echo] Refreshing app at /home/apache/http/tiunesco/www
[INF]
[INF] app-refresh-impl:
[INF]
[INF] -before-init-local:
[INF]
[INF] -init-local:
[INF]
[INF] -after-init-local:
[INF]
[INF] init-local:
[INF]
[INF] find-cmd-in-path:
[INF]
[INF] find-cmd-in-environment:
[INF]
[INF] find-cmd-in-shell:
[INF]
[INF] init-cmd:
[INF] [echo] Using Sencha Cmd from /opt/Sencha/Cmd/4.0.1.45 for /home/apache/http/tiunesco/www/build.xml
[INF]
[INF] -before-init:
[INF]
[INF] -init:
[INF] Initializing Sencha Cmd ant environment
[INF] Adding antlib taskdef for com/sencha/command/compass/ant/antlib.xml
[INF]
[INF] -after-init:
[INF]
[INF] -before-init-defaults:
[INF]
[INF] -init-defaults:
[INF]
[INF] -after-init-defaults:
[INF]
[INF] -init-compiler:
[INF]
[INF] init:
[INF]
[INF] refresh:
[INF]
[INF] -before-refresh:
[INF]
[INF] -init:
[INF]
[INF] -init-compiler:
[INF]
[INF] -detect-app-build-properties:
[INF] Loading app json manifest...
[INF] Loading classpath entry /home/apache/http/tiunesco/www/touch/src
[INF] Loading classpath entry /home/apache/http/tiunesco/www/app.js
[INF] Loading classpath entry /home/apache/http/tiunesco/www/app
[INF] Loading classpath entry /home/apache/http/tiunesco/www/build/temp/production/TiUNESCO/sencha-compiler/app
[WRN] C1000: Rhino Parse Warning (Trailing comma is not legal in an ECMA-262 object initializer => },) -- /home/apache/http/tiunesco/www/app/view/PicView.js:22:5
[ERR] C2008: Requirement had no matching files (Ext.locale.Manager) -- /home/apache/http/tiunesco/www/app.js:33:222
[ERR]
[ERR] BUILD FAILED
[ERR] com.sencha.exceptions.ExBuild: Failed to find any files for /home/apache/http/tiunesco/www/app.js::ClassRequire::Ext.locale.Manager
[ERR]
[ERR] Total time: 3 seconds
[ERR] The following error occurred while executing this line:
/opt/Sencha/Cmd/4.0.1.45/plugins/touch/2.3/plugin.xml:326: The following error occurred while executing this line:
/home/apache/http/tiunesco/www/.sencha/app/build-impl.xml:367: The following error occurred while executing this line:
/home/apache/http/tiunesco/www/.sencha/app/js-impl.xml:11: com.sencha.exceptions.ExBuild: Failed to find any files for /home/apache/http/tiunesco/www/app.js::ClassRequire::Ext.locale.Manager
/s/h/t/www git:master ???

mitchellsimoens
15 Jan 2014, 8:18 AM
First, why did you rename it? Please do not rename my code.

arael78
15 Jan 2014, 8:21 AM
First, why did you rename it? Please do not rename my code.

Sorry, I did it only because I thought this would allow me to create a production build. That is the only reason. I thought that putting the code in the touch/src folder would make it available to the sencha command.

mitchellsimoens
15 Jan 2014, 8:24 AM
You shouldn't touch the touch directory. Instead you should have the code somewhere else in you app and then edit the app.classpath property in the .sencha/app/sencha.cfg file. This is where it tells what directories to inspect.

arael78
15 Jan 2014, 8:29 AM
You shouldn't touch the touch directory. Instead you should have the code somewhere else in you app and then edit the app.classpath property in the .sencha/app/sencha.cfg file. This is where it tells what directories to inspect.

Ok. So I suppose this is the variable I should modify: app.resource.paths.

What is the best practice. Should I put the Ux.locale.Manager code inside the package directory?

EDIT: As a quick test I have set this: app.resource.paths=${app.dir}/touch/src/locale and the problem persists.

arael78
15 Jan 2014, 8:39 AM
The correct variable was: app.classpath just like you wrote.

Sorry but it is 17:40 here and I'm quite tired so I overlooked it. (:|

Thank you very much for your help.

I'll revert the change Ext.locale.Manager to Ux.locale.Manager as it was before.

Is the package directory the appropriate place for your code?

mitchellsimoens
15 Jan 2014, 8:48 AM
You can place the code wherever makes sense for you. The package directory is meant to be used for Cmd packages.

arael78
15 Jan 2014, 8:50 AM
Ok. Is there a packaged version of the locale manager?

In the end I created a directory "extensions". It seems the most appropriate to me. Polluting the packages directory doesn't seem to be a good idea.

Really, thank you for all the patience. =)

bkhosravi
27 Jan 2014, 2:34 PM
This component does not exist on the market. is it still being worked on? is there an alternative?..I really like it as it is the only locale manager I have found so far for extjs.

Thanks.

egomezd
9 May 2014, 4:53 AM
Hi,Im new on Sencha, in fact I am finishing my first app. I have a couple of selectfields that the do not use datastorage and I would like to use Ux.locale.Manager to change the options value depending on the language selected by the user. Also I need to change the texts in doneButton and cancelButton. Ive tried with the code provided by @armode for changing the text field in the options but no texts are shown by my selectfields.Help would be very appreciated. Thanks in advance.

armode
12 May 2014, 6:22 AM
You have to override the selectfield to to change the options value. I guess that the selectfield is using a store even if you set static data. So you would have to update the store's data or update your options.

Which code did you try to use to translate the buttons?
The selectfield is using Ext.picker.Picker and the buttons belong to that class. Have a look at this override: https://github.com/mitchellsimoens/Ux.locale.Manager/blob/master/Ux/locale/override/st/picker/Picker.js

egomezd
14 May 2014, 2:52 AM
Thank so much for your help @armode.Ive resolved the problem with the literals in done and cancel button reviewing the link you sent.Regarding the options in the selecfield, my level in Sencha is not enough good yet to override the selectfield class on my own but, following your advice, Ive used a store to save the data. Ive written the data in each language.json file and I recover the data using a proxy in the store in this way:
config: { autoLoad: true, model: 'Unit', storeId: 'UnitsStore', proxy: { type: "ajax", url : 'locales/en.json', reader: { type: "json", rootProperty: "options" } } In the initialize function, I find out the language I have to use in the proxy url:
initialize: function() { var mystore = Ext.data.StoreManager.lookup ('UnitsStore'); var language = Ux.locale.Manager.getLanguage(); var myurl = "locales/" + language + '.json'; mystore.getProxy().setUrl(myurl); mystore.load(); } //end function initializeI dont know if its a good solution but its working.

shellgrit
17 Jun 2014, 2:23 AM
My app stores the users selected language (and other settings) in Local Storage and retrieves them via the launch function of my Settings Controller. Based on the language, it then sets the store to be used (ie. either the "English" or "Chinese" store).

I have two problems:
How do I retrieve the full name of a language from Ux.locale.Manager, as the getLanguage function only returns the abbreviation for the language (ie. "en" or "zh"), but I would like to get the full name (ie. "English" or "Chinese")? I need this so that I can set the store to either "English" or "Chinese" and remove the hard coding I have at the moment (and therefore be able to support additional languages without coding changes).
I need to set the badgeText for a tab based on another setting retrieved from Local Storage and this text needs to be in the selected language. I have tried doing this via the get function, however it seems that Ux.locale.Manager isn't operational when my launch function runs, as the isLoaded function always returns false. When I use the get function to do the same thing outside my launch function it works fine and isLoaded returns true.
Hope this makes sense :)

shellgrit
23 Jun 2014, 3:40 AM
I have solved problem number 1 - how to get the "full name" of a language.

The function getAvailable returns an array of objects, with each object containing "abbr" & "text" value pairs for each language. So I can search through the array until I find the matching "abbr" and retrieve the corresponding "text".

Here is the code:



var languages = Ux.locale.Manager.getAvailable(true),
l = 0,
lNum = languages.length;
for (; l <lNum; l++) {
if (languages[l].abbr == value) {
... do whatever ... ;
break;
}
};


Hope this makes sense :)

sbaner09
7 Nov 2014, 6:26 AM
First of all It's Excellent Extension to work with.
I am able to localized months in Date Picker control, but not the selected value


{
xtype: 'datepickerfield',
locales: {
label: 'datepickerfield.label'
},
name: 'DatePicker',
dateFormat: 'd M Y',
picker: {
enableLocale: true,
locales: {
months: 'months'
},
yearFrom: 2012,
doneButton: {
locales: {
text: 'buttons.done'
}
},
cancelButton: {
locales: {
text: 'buttons.cancel'
}
}
}
}
Now even if my application is in French language, selected value in Date Picker still coming in English. shown Below,

50937

Is there any configuration which is missing ?