Skip to content

Instalation instruction for Noobs #6

@ghost

Description

Create dir:
TranslatableDataObject
_config.php => empty
TranslatableDataObject\code\TranslatableDataObject.php

Copy to server main dir not into mysite\code\ single file class

Otherwise class will be load before i18n and lang will be default en_us to all pages
__

Translatable::set_default_locale('en_US');
Translatable::set_allowed_locales(array('en_US', 'it_IT'));
SiteTree::add_extension('Translatable');

TranslatableDataObject::set_langs(array(
'IT',
'EN'
));

Don't try en_US', 'it_IT:

In Page.php add:

public function init() {
parent::init();
if($this->dataRecord->hasExtension('Translatable')) {
i18n::set_locale($this->dataRecord->Locale);
}
}

Finally:

foreach($this->getTranslationFields(null, "IT") as $field) {
        $f->addFieldToTab("Root.IT", $field);
    }

not

foreach($this->getTranslationFields(null, "it_IT") as $field) {
    $f->addFieldToTab("Root.IT", $field);
}

__

Its hard to be Silverstripe noob ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions