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

(Solved) translation in .php


Reply

6 Posts   1095 Views

Avatar
Webdoc

19 September 2010 at 5:37am (Last edited: 22 September 2010 9:08am), Community Member, 332 Posts

How to translate the array-s in php and how to setup them in lang file

Avatar
Willr

19 September 2010 at 12:09pm Forum Moderator, 5511 Posts

Have a read of the documentation on http://doc.silverstripe.org/i18n. That should have all you need to know!

Avatar
Webdoc

19 September 2010 at 7:18pm Community Member, 332 Posts

"Enum('_t('Objekt.KORTER');, _t('Objekt.MAJA');, _t('Objekt.ARIPIND');, _t('Objekt.SUVILA');, _t('Objekt.RIDAELAMU');, _t('Objekt.PAARISMAJA');, _t('Objekt.MAATYKK');')"

gives error:
184             case T_STRING:
185                switch($token[1]) {
186                   case 'true': $args[] = true; break;
187                   case 'false': $args[] = false; break;
188                   default: throw new Exception("Bad T_STRING arg '{$token[1]}'");

Avatar
Webdoc

21 September 2010 at 1:48am Community Member, 332 Posts

is it even possible to make translateable the enum and then the searchable field title

Avatar
Willr

21 September 2010 at 12:25pm Forum Moderator, 5511 Posts

You can't have translations in Enums (as that would make the enum pretty useless). You have to pick a single language from the enum. If you want to translate the labels you can use if ($x = "Foo") .. $label = _t('FOO', 'Foo'); to translate it. Note you also can't use variables inside a _t() as that too would make things not work.

Avatar
Webdoc

22 September 2010 at 9:08am Community Member, 332 Posts

Tnx
made it easier way used:
$form->disableSecurityToken();
for search so i was able to made search template myself with costum code no need for securityID

and for enums added both languages in one enum they where only needed for filtered search.