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

Translatable and PHP language tables


Reply


6 Posts   1368 Views

Avatar
karibe

Community Member, 56 Posts

19 August 2009 at 10:34pm

Hello

I'm upgrading my old page based on ss 2.2.3 to new 2.3.3 wit new multilang future.
The problem is that I have static typed form in page type ContacPage.php with labels like name surname, subject ...
This problem is common in many cases so I red in doc that there is something like php language tables.
I made in mysite/lang two files pl_PL.php and en_US.php and in contact form:

new TextField(_t('ContactForm.NAMESURNAME', "ImiÄ™ i Nazwisko")

where in pl_PL.php I have :

$lang['pl_PL']['ContactForm']['NAMESURNAME'] = 'foo:';

What I'm doing wrong?
Maybe there is some better way to do same?

Avatar
dendeffe

Community Member, 135 Posts

20 August 2009 at 12:48am

Hmmm I guess this is more or less the same question as my post: [url]http://www.silverstripe.org/general-questions/show/267119#post267119[/url]. Basically, more info and examples on the locale files.

Avatar
karibe

Community Member, 56 Posts

20 August 2009 at 1:15am

Yes we need same functionality:)

Avatar
Xeal

Community Member, 37 Posts

20 August 2009 at 2:30am

add this line into your mysite/_config.php file
Object::add_extension('SiteTree', 'Translatable');

and then add this to your Page_Controller in mysite/code/Page.php
if($this->dataRecord->hasExtension('Translatable')) {
   i18n::set_locale($this->dataRecord->Locale);
}

That should do the trick

Avatar
dendeffe

Community Member, 135 Posts

20 August 2009 at 4:09am

Thanks Xeal.

Don’t know if this solves my problem though. I get a blank page if I add that code to the Page_Controller.

Avatar
karibe

Community Member, 56 Posts

20 August 2009 at 6:20pm

Cool works for me if pasted in PageController::init() method