21280 Posts in 5729 Topics by 2600 members
| Go to End | Next > | |
| Author | Topic: | 2079 Views |
-
How to translate fields labels

24 September 2010 at 7:41am
I'd like to translate fields of custom data object
static $db = array(
'Title' => 'Varchar(100)'
);
I tried: $lang['lang']['Product']['db_Title'] = 'Name'; and function fieldLabels () {$labels['Title'] = 'Name';}But getting error in TableField class
line 135: $class = $this->fieldTypes[$fieldName];'cos
$this->fieldList looks like array( 'Title' => 'Title');
but $this->fieldTypes became array ('Name' => 'Varchar(100)') -
Re: How to translate fields labels

24 September 2010 at 8:28am
Add this to you DataObject:
function fieldLabels() {
$labels = parent::fieldLabels();
$labels['Title'] = _t('SomeDataObject.Title', "SomeTranslatableTitle");return $labels;
} -
Re: How to translate fields labels

24 September 2010 at 8:52am Last edited: 24 September 2010 8:54am
Yes, I tried as I said before, but anyway I'm getting error from TableField class
I think that should be:
$this->fieldList = array( 'FIELDNAME' => 'FIELDLABEL');
and
$this->fieldTypes = array( 'FIELDNAME' => 'FIELDTYPE');
But I'm getting:
$this->fieldList = array( 'FIELDNAME' => 'FIELDNAME');
$this->fieldTypes = array( 'FIELDLABEL' => 'FIELDTYPE');That's why when FieldTable class parses $this->fieldList array and trying to get $this->fieldTypes['FIELDNAME'] property it gets nothing, so I think it's core error somewhere but I can't find where.
Both mentioned methods of translation works perfectly anywhere but not with TableField
-
Re: How to translate fields labels

24 September 2010 at 9:10am
Hmm .. I made an experiment
class WareAdmin extends ModelAdmin {
public static $managed_models = array(
'Product'
);static $url_segment = 'warehouse';
static $menu_title = 'Ware House Control';
function getEditForm(){
return $this->bindModelController('Product')->ResultsForm(array());
}
}Field translation works fine with ModelAdmin, but doesn't work in PanelModelAdmin
-
Re: How to translate fields labels

24 September 2010 at 11:00am
Trunk is updated for translatable Heading Labels in TableField.
http://svn.axyrmedia.nl/panelmodeladmin/trunk/
Please let me know if this works for you..
-
Re: How to translate fields labels

25 September 2010 at 6:33pm
hey, does this SilverStripe have localization tool? for instance on trasifix.net? How translators will work? I did not find any clue on the website. someone plz give me a hint thanks.
-
Re: How to translate fields labels

25 September 2010 at 7:54pm
Here's manual
http://doc.silverstripe.org/i18nfor field labels just add to mysite/lang/*lang*.php
$lang[*lang*][*Classname*]['db_*fieldname*] = "Field translation";
| 2079 Views | ||
| Go to Top | Next > |



