设置:SS 3.1.13、Translatable 2.0.8 和 TranslatableDataObject dev-master。
我有两个 DataObject 类:“Facility”($has_one)和“FacilityType”($has_many),我选择在 ModelAdmin 中进行管理(因为它们是站点所有者的全局属性)。但是,尽管仔细阅读了此处的设置说明,但我无法获得 TranslatableDataObject 扩展以实际为它们启用翻译。
这是我的 _config.php:
// Set the site locale
i18n::set_locale('en_US');
SiteConfig::add_extension('Translatable');
// Set allowed locales
Translatable::set_allowed_locales(array('en_US', 'pl_PL'));
TranslatableDataObject::set_locales(array('en_US', 'pl_PL'));
Facility::add_extension("Translatable");
Facility::add_extension("TranslatableDataObject"); // tried "TranslatableDataObject('Title')" as well
FacilityCategory::add_extension("Translatable");
FacilityCategory::add_extension("TranslatableDataObject");
任何人都可以确认此设置应该或不会为我工作吗?
FacilityCategory.php
class FacilityCategory extends DataObject {
private static $db = array(
'Title' => 'Varchar'
);
private static $has_many = array(
'Facilities' => 'Facility.FacilityCategory'
);
public function getCMSFields(){
$fields = FieldList::create(
TextField::create('Title')
);
return $fields;
}
}
class FacilityCategoryAdmin extends ModelAdmin {
private static $menu_title = 'Facility Categories';
private static $url_segment = 'facility-categories';
private static $managed_models = array(
'FacilityCategory'
);
}
设施.php
class Facility extends DataObject {
private static $db = array(
'Title' => 'Varchar',
);
private static $has_one = array(
'Category' => 'FacilityCategory'
);
private static $summary_fields = array(
'Title' => 'Name',
'Category.Title' => 'Type'
);
public function getCMSFields(){
$fields = FieldList::create(
TextField::create('Title'),
DropdownField::create('CategoryID', 'Category')
->setSource(FacilityCategory::get()->map()->toArray())
->setEmptyString('-- select a category --')
);
return $fields;
}
}
class FacilityAdmin extends ModelAdmin {
private static $menu_title = 'Facilities';
private static $url_segment = 'facilities';
private static $managed_models = array(
'Facility'
);
}