Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » i18n - translation of new CMSFields

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1013 Views
  • François
    Avatar
    25 Posts

    i18n - translation of new CMSFields Link to this post

    I extended the Page class to define a new ChantierPage with two new CMSFields. Here is the relevant code:

    class ChantierPage extends Page {

    static $db = array (
    'Date' => 'Date',
    'Location' => 'Text'
    );

    static $has_one = array ();
       
    function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new TextField('Location'), 'Content');
    return $fields;
    }
    }

    class ChantierPage_Controller extends Page_Controller { }

    When I translate a ChantierPage only the default fields (Title, Content) gets translated. My new 'Location' TextField is not shown in the admin page when in translating mode.

    But, when I create the translation, new rows are added to the "ChantierPage" table. However there is no reference to those new rows in any SiteTree tables.

    Do I have missed a point? What can I do to make this new TextField translation-aware?

    Thanks for any help.
    Cheers

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: i18n - translation of new CMSFields Link to this post

    You guessed right, you need to explicity make the fields "translation-aware", see http://doc.silverstripe.com/doku.php?id=multilingualcontent

  • François
    Avatar
    25 Posts

    Re: i18n - translation of new CMSFields Link to this post

    Thanks for your answer.

    But I already tried that. When I try this:

    static $db = array (
    'Date' => 'Date',      
    'Author' => 'Text',
    'CustomText' => 'Text'
    );
    static $extensions = array("Translatable('CustomText')");

    after I rebuild the db I receive lots of error. I can't even display the admin page. The main error is:

    FATAL ERROR: Object::__call() Method 'markUnexpanded' not found in class 'ArticlePage'

    I'm stuck there

    Now I'm evaluating the possibility to manage the languages on my client's site by using one page tree per language, and completely forget about the i18n extension in SS. I hope I'll be able to find a working and acceptable solution for my client otherwise I will have no choice but to say bye-bye to SilverStripe

    I would like to help regarding the i18n implementation, and I hope to find some time to dive in the code and see what I can do to help.

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: i18n - translation of new CMSFields Link to this post

    The "one tree per language" is an often used fallback, albeit not very handy as it creates duplicate data. Unfortunately the i18n extensions in SilverStripe are still pretty early stage - we're improving the situation on a feature branch which will find its way into a release at some point. If you want to follow its progress, have a look at http://open.silverstripe.com/browser/modules/sapphire/branches/translatable and http://open.silverstripe.com/browser/phpinstaller/branches/translatable

    We can really use any help on this effort, depending on your PHP5 skills and SS knowledge this might be contributing to its development, but even checking out this project, testing and writing detailed bugreports helps us a lot. Let me know if you want to get involved here!

  • François
    Avatar
    25 Posts

    Re: i18n - translation of new CMSFields Link to this post

    Thanks for the links.

    I sure will try to help. As a freelancer I'm already overbooked but I'll find the time to contribute to SS success.

    1013 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.