Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

i18n - translation of new CMSFields


Go to End


5 Posts   1434 Views

Avatar
François

25 Posts

18 October 2008 at 9:31pm

Edited: 18/10/2008 9:38pm

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

Avatar
Ingo

Forum Moderator, 801 Posts

1 November 2008 at 11:39am

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

Avatar
François

25 Posts

1 November 2008 at 10:53pm

Edited: 01/11/2008 10:54pm

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.

Avatar
Ingo

Forum Moderator, 801 Posts

1 November 2008 at 11:55pm

Edited: 01/11/2008 11:57pm

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!

Avatar
François

25 Posts

2 November 2008 at 4:06am

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.