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.

Data Model Questions /

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

Problems with Translatable & 2.3.1


Go to End


7 Posts   3000 Views

Avatar
lazerscience

Community Member, 16 Posts

1 May 2009 at 6:00am

Hi,
I'm working on my first multilingual site with SS and I'm having troubles with the translatable class!
I was trying to do everything according to http://doc.silverstripe.com/doku.php?id=multilingualcontent but could not get anything working at all!

First I tried putting

Translatable::set_default_locale(<locale>);
in my _config.php, but this function doesnt seem to exist in my Ss version in the Translatable class!

Furthermore if i try

Object::add_extension('Page', 'Translatable');
in _config.php or
	static $extensions = array(
    "Translatable"
  );
in Page.php the result is always resulting in
[Warning] Missing argument 1 for Translatable::__construct()

I think I have to pass somehow the translatable fields to the decorator, but don't know how to do that!

All in all i would just need a quick version to make all content translatable, and the site will feature at least 4 languages, so work arounds like creating seperate fields for languages doesnt really work, and translateable as shown in the tutorial would be perfect for me, but no idea how to get that working, any fast help is really appreciated! thanks!

Avatar
masonz

Community Member, 1 Post

1 May 2009 at 4:42pm

I've funnily enough been working through the exact same problem today; I've managed to enable the module using:

Translatable::enable();

And then doing a dev/build, however this still doesn't work correctly. I get an error message when trying to create a new translation:

Error: Couldn't run query: SELECT `SiteTree`.*, `SiteTree_lang`.*, `SiteTree_lang`.*, `GhostPage`.*, `ErrorPage`.*, `RedirectorPage`.*, `VirtualPage`.*, `UserDefinedForm`.*, `SiteTree_lang`.OriginalLangID, if(`SiteTree_lang`.ClassName,`SiteTree_lang`.ClassName,'SiteTree') AS RecordClassName, `SiteTree_lang`.OriginalLangID AS ID, `SiteTree_lang_lang`.OriginalLangID AS ID FROM INNER JOIN `SiteTree_lang` ON `SiteTree_lang`.OriginalLangID = `SiteTree_lang`.OriginalLangID INNER JOIN `SiteTree` ON `SiteTree_lang`.OriginalLangID = `SiteTree`.ID LEFT JOIN `GhostPage` ON `GhostPage`.ID = `SiteTree_lang`.OriginalLangID LEFT JOIN `ErrorPage` ON `ErrorPage`.ID = `SiteTree_lang`.OriginalLangID LEFT JOIN `RedirectorPage` ON `RedirectorPage`.ID = `SiteTree_lang`.OriginalLangID LEFT JOIN `VirtualPage` ON `VirtualPage`.ID = `SiteTree_lang`.OriginalLangID LEFT JOIN `UserDefinedForm` ON `UserDefinedForm`.ID = `SiteTree_lang`.OriginalLangID WHERE (`SiteTree`.`ParentID` = 0 AND `SiteTree_lang`.OriginalLangID != 0) AND (`SiteTree_lang`.Lang = 'de') AND (`SiteTree_lang`.Lang = 'de') ORDER BY Sort You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN `SiteTree_lang` ON `SiteTree_lang`.OriginalLangID = `SiteTree_lang`.O' at line 1

Anyway, any further ideas anyone? From as far as I can see the fix is to use the SVN trunk; is it safe to use yet?

Avatar
Kalileo

Community Member, 127 Posts

1 May 2009 at 6:26pm

You guys might have noticed that translatable does not work currently, with 2.3.1 and I think also 2.3.0, it's mentioned quite often here.

However that should not stop you from making multilanguage sites even with 2.3.1, see recipes:multilingual_content and Multilingual Content - alternative to 'translatable'.

Avatar
lazerscience

Community Member, 16 Posts

1 May 2009 at 11:14pm

Edited: 01/05/2009 11:51pm

As I mentioned above it's not a nice aternative for me to make seperate fields for seperate languages since the site will feature 4+ languages and probably grow! But you think there's no chance of getting Translatable work with 2.3.1?

Is there anybody out there who managed to get Translatable working with 2.3.1 and can post his code?

Avatar
keeny

Community Member, 48 Posts

6 May 2009 at 10:24am

It definately doesn't work with 2.3.1. I'm currently trying out 2.3.2beta1 which you can check out via svn. So far no luck tho... when I change the locale using

http://<mysite>/mypage/?locale=de_DE
I just get an error: The requested page couldn't be found.

Avatar
keeny

Community Member, 48 Posts

6 May 2009 at 1:04pm

Okay, so now I see each page has a unique url. So If I have an english version of home at http://mysite.com/home/ to get to the japanese version, I have to visit http://mysite.com/home-ja-JP/?locale=ja_JP

BUT the locale is not persisted.

If I then try to visit the about page by clicking a link in the navigation it goes to http://mysite.com/about-ja-JP/ and I get the error 'The requested page couldn't be found.'

I have to explicitly visit http://mysite.com/about-ja-JP/?locale=ja_JP.

Does anyone know how to make the locale persistant, so that once the user visits a Japanese page, the site STAYS in Japanese until they choose to switch back to English?

Cheers,

Barry.

Avatar
Ingo

Forum Moderator, 801 Posts

11 May 2009 at 8:34pm