PDA

View Full Version : Language Selection



gabrielstuff
28 Oct 2010, 8:26 AM
Hello,
Where can we setup a language file ?
For example how to change the DONE button label that is setup deep into Select and in HARD :

donetext : "Done"...

All the picker stuff should be setupable ? right ?

Here is what I've done. I've overwritten the onMaskTap function for select field just to add this.picker.doneText = "OK".
Seems quiete slugish to me.



onMaskTap : function() {
if (Ext.is.Phone) {
this.picker = new Ext.Picker({
slots: [{
align: 'center',
name: this.name,
valueField: this.valueField,
displayField: this.displayField,
value: this.getValue(),
store: this.store
}],
listeners: {
change: this.onPickerChange,
hide: this.onPickerHide,
scope: this
}
});
this.picker.doneText = "OK";
this.picker.show();
}
else {
this.list = new Ext.List({
store: this.store,
tpl: [
'<tpl for=".">',
'<div class="x-list-item">',
'<span class="x-list-label">{' + this.displayField + '}</span>',
'<span class="x-list-selected"></span>',
'</div>',
'</tpl>'
],
itemSelector: '.x-list-item',
floating: true,
stopMaskTapEvent: true,
hideOnMaskTap: true,
singleSelect: true,
listeners: {
selectionchange: this.onListSelect,
scope: this
}
});
this.list.showBy(this.el, 'fade', false);
var index = this.store.find(this.valueField, this.value);
this.list.select(index != -1 ? index : 0, false, true);
}
}
}]
},



Thanks !

nanotron
29 Oct 2010, 12:30 AM
Hi,

there was a Language-File in the 0.96 Release (src/locale/).
This is a good starting point.

Best regards

gabrielstuff
29 Oct 2010, 12:40 AM
Thanks for the tips. Under 0.95 and 0.98 I can not see this file...
But, even with a "magic" language file I do not get how it could modify something that is written with no paramaters... look into picker.js :


Ext.Picker = Ext.extend(Ext.Sheet, {
/**
* @cfg {String} cmpCls
* The main component class
*/
cmpCls: 'x-picker',

stretchX: true,
stretchY: true,
hideOnMaskTap: false,

/**
* @cfg {String} doneText
* The text to be used on the done button if {@link #showDoneButton} is true.
* Defaults to 'Done'.
*/
doneText: 'Done',

Any more hints ?

evant
29 Oct 2010, 12:42 AM
As suggested by @nanotron, you need to create a language file similar to the one in /src/locale and include it after ext-touch.

It applies the local language to the prototypes of the objects.

nanotron
29 Oct 2010, 12:46 AM
You have to define the doneText in the config object:


new Ext.Picker({
doneText: 'Yeah',
...
});

gabrielstuff
29 Oct 2010, 12:47 AM
Sorry to insist, but I've just downloaded the 0.98 release and here is what I get in src:

src/core
src/data
src/gestures
src/ayout
src/platform
src/util


Doing a search on "language" didn't help... Am I blind this morning ? Thanks for the help.
widgets

gabrielstuff
29 Oct 2010, 12:49 AM
That is exactly what I am doing... but here we are talking about select in form which call the picker. And the select field object is the one that instanciate the picker. That is why I am overwrittent the
onMaskTap function...

Any more ideas ?

nanotron
29 Oct 2010, 12:49 AM
But in the 0.95 Release (http://www.sencha.com/products/touch/thank-you.php?dl=publicbeta095)

evant
29 Oct 2010, 12:50 AM
For whatever reason it's not coming up in the build. Here's the file:



Date.dayNames = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
];

Date.monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];

Date.monthNumbers = {
'Jan': 0,
'Feb': 1,
'Mar': 2,
'Apr': 3,
'May': 4,
'Jun': 5,
'Jul': 6,
'Aug': 7,
'Sep': 8,
'Oct': 9,
'Nov': 10,
'Dec': 11
};

Date.getShortMonthName = function(month) {
return Date.monthNames[month].substring(0, 3);
};

Date.getShortDayName = function(day) {
return Date.dayNames[day].substring(0, 3);
};

Date.getMonthNumber = function(name) {
return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
};

Date.parseCodes.S.s = '(?:st|nd|rd|th)';

if(Ext.Picker){
Ext.override(Ext.Picker, {
doneText: 'Done'
});
}

if(Ext.DatePicker){
Ext.override(Ext.DatePicker, {
'dayText': 'Day',
'monthText': 'Month',
'yearText': 'Year',
'slotOrder': ['month', 'day', 'year']
});
}

if(Ext.IndexBar){
Ext.override(Ext.IndexBar, {
'letters': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
});
}

if(Ext.NestedList){
Ext.override(Ext.NestedList, {
'backText': 'Back',
'loadingText': 'Loading...',
'emptyText': 'No items available.'
});
}

if(Ext.util.Format){
Ext.util.Format.defaultDateFormat = 'm/d/Y';
}

gabrielstuff
29 Oct 2010, 12:54 AM
Thanks !!!!!
I try that !
Any idea if it is working with 0.95 ? when does it get supported ? Thanks again, maybe this file should be in the 0.99 release :)

blessan
29 Oct 2010, 4:11 AM
just take the file and put in 98 release. Might work.

gabrielstuff
29 Oct 2010, 5:22 AM
And !!!! It is working like a charm. Thanks.



if(Ext.Picker){
Ext.override(Ext.Picker, {
'doneText': 'OK'
});
}