Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9 from miguelocarvajal/master

Plural words, FieldContainer and MenuItem
  • Loading branch information...
commit ea25b9c26593eda984dcb1720acb2ee2138736f8 2 parents 7ddebb7 + a68b7e0
@mitchellsimoens mitchellsimoens authored
View
15 Ux/locale/Manager.js
@@ -115,9 +115,11 @@ Ext.define('Ux.locale.Manager', {
get : function(key, defaultText) {
var me = this,
locale = me._locale,
- keys = key.split('.'),
+ plural = key.indexOf('p:') == 0,
+ keys = (plural ? key.substr(2) : key).split('.'),
k = 0,
- kNum = keys.length;
+ kNum = keys.length,
+ res;
if (!me.isLoaded()) {
return defaultText;
@@ -131,7 +133,12 @@ Ext.define('Ux.locale.Manager', {
}
}
- return locale || defaultText;
+ res = locale || defaultText;
+
+ if (plural)
+ return Ext.util.Inflector.pluralize(res);
+ else
+ return res;
},
getAvailable : function(simple) {
@@ -156,4 +163,4 @@ Ext.define('Ux.locale.Manager', {
getLanguage : function(){
return this._language;
}
-});
+});
View
38 Ux/locale/override/extjs/FieldContainer.js
@@ -0,0 +1,38 @@
+Ext.define('Ux.locale.override.extjs.FieldContainer', {
+ override : 'Ext.form.FieldContainer',
+
+ requires : [
+ 'Ux.locale.override.extjs.Component'
+ ],
+
+ setLocale : function(locale) {
+ var me = this,
+ locales = me.locales,
+ text = locales.fieldLabel,
+ manager = me.locale,
+ defaultText = '';
+
+ if (text) {
+ if (Ext.isObject(text)) {
+ defaultText = text.defaultText;
+ text = text.key;
+ }
+
+ text = manager.get(text, defaultText);
+
+ if (Ext.isString(text)) {
+ me.setFieldLabel(text);
+ }
+ }
+
+ me.callOverridden(arguments);
+ },
+
+ setFieldLabel : function(text) {
+ this.labelEl.update(text);
+
+ this.fieldLabel = text;
+
+ return this;
+ }
+});
View
30 Ux/locale/override/extjs/MenuItem.js
@@ -0,0 +1,30 @@
+Ext.define('Ux.locale.override.extjs.MenuItem', {
+ override : 'Ext.menu.Item',
+
+ requires : [
+ 'Ux.locale.override.extjs.Component'
+ ],
+
+ setLocale : function(locale) {
+ var me = this,
+ locales = me.locales,
+ text = locales.text,
+ manager = me.locale,
+ defaultText = '';
+
+ if (text) {
+ if (Ext.isObject(text)) {
+ defaultText = text.defaultText;
+ text = text.key;
+ }
+
+ text = manager.get(text, defaultText);
+
+ if (Ext.isString(text)) {
+ me.setText(text);
+ }
+ }
+
+ me.callOverridden(arguments);
+ }
+});
Please sign in to comment.
Something went wrong with that request. Please try again.