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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

i18N questions in 2.3.2


Reply


2 Posts   1119 Views

Avatar
ChrisBryer

Community Member, 95 Posts

9 June 2009 at 4:16am

Hi Everyone,
I am working on a multi-lingual site and have had a few problems in 2.3.2-rc2. Documentation is pretty sparse on how to get started with multi-lingual stuff with 2.3.2.

The first big question is regarding the lang directory. i put the lang folder in mysite, and english text is pulled from it (en_US.php) but when i switch to de_DE locale, it is not pulling anything from de_DE.php. here is a sample of what i have set up:

(en_US.php)
<?php

global $lang;
$lang['en_US']['Page']['TAGLINE'] = 'Tag line';
?>

(de_DE.php)
<?php

global $lang;
$lang['de_DE']['Page']['TAGLINE'] = 'German Tag line';
?>

(page.ss)
<% _t('Page.TAGLINE') %>

Another problem that i get is with hasmanycomplextablefields. if i have one DataObject checked on an english version, when i switch to a german locale the same DataObject is disabled and the box is grayed out. I assume its because the Dataobject is already associated with the page, however content from the DO doesnt show up on the front side.

A third problem is that when i try to edit or add a dataobject to a CTF in a non-default locale, I get a message in the popup saying 'I can't handle sub-URL's of a CMSMain object' and no information from the dataobject is displayed. this happens when the url in the admin section is something like admin/show/1376/?locale=de_DE. in a dailybuild from last week (i think around 6/3) i was getting this in imagefields too but that doesnt happen in the older rc2.

My last question is dealing with the homepage. when i translate the site to german, the german homepage url becomes /home-2. This is messing up my templates because i have a home button that goes back to the english homepage from a german locale. none of my other pages change urls when translated, so i'm not sure why the homepage does change urls. we also have several domains (mysite.com, mysite.de, etc) and I'd like to make the mysite.de default to the german translation, but i'm not sure what the best way is to set this up... are people leaning towards subdomains, cookies/sessions, _GET params?

any help or suggestions would be appreciated,
-Chris

Avatar
ChrisBryer

Community Member, 95 Posts

9 June 2009 at 8:11am

I realized that the locale wasnt being set so it wasnt reading de_DE.php. if there's anyone out there that's having the same problems as me, here's how to fix the local problem:

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

I'm still trying to figure out the homepage issues.