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.

General Questions /

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

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

(Solved) translation in .php


Go to End


6 Posts   1449 Views

Avatar
Webdoc

Community Member, 349 Posts

19 September 2010 at 5:37am

Edited: 22/09/2010 9:08am

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

Avatar
Willr

Forum Moderator, 5523 Posts

19 September 2010 at 12:09pm

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

Avatar
Webdoc

Community Member, 349 Posts

19 September 2010 at 7:18pm

"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

Community Member, 349 Posts

21 September 2010 at 1:48am

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

Avatar
Willr

Forum Moderator, 5523 Posts

21 September 2010 at 12:25pm

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

Community Member, 349 Posts

22 September 2010 at 9:08am

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.