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.

Form Questions /

Multilingual Form


Reply


4 Posts   1053 Views

Avatar
swaiba

Forum Moderator, 1804 Posts

7 July 2010 at 9:00pm

Hello,

I am creating a website for different languages and would like to use an ss Form like http://doc.silverstripe.org/recipes:forms, but with much more stuff. How can I make this multilingual in the most efficient way?

I am using the Translatable and at the moment if I want to allow more languages I just add the locales in the _config.php, but now I'd have to do more for each translation of the form?

Barry

Avatar
Gaster

Community Member, 1 Post

4 August 2010 at 2:56am

You can use a [url=http://phpforms.net/tutorial/html-basics/form-builder.html]form builder[/url] for creating such forms. As I know one of its versions has multilingual option

Avatar
Devlin

Community Member, 217 Posts

5 August 2010 at 6:33am

Edited: 05/08/2010 6:39am

You can also use the _t function.
[url]http://doc.silverstripe.org/i18n#the_t_function[/url]

new FieldSet(
   new TextField("FirstName", _t("FORM23.FIRSTNAME","First name") ),
)

Then add a lang folder to your project folder and create language tables.
[url]http://doc.silverstripe.org/i18n#language_tables_in_php[/url]

$lang['en_US']['FORM23']['FIRSTNAME'] = 'First name';
$lang['de_DE']['FORM23']['FIRSTNAME'] = 'Vorname';
$lang['ar_EG']['FORM23']['FIRSTNAME'] = '????? ??????';
$lang['nl_NL']['FORM23']['FIRSTNAME'] = 'Voornaam';

This is working very well for me on several webpages.

Avatar
swaiba

Forum Moderator, 1804 Posts

5 August 2010 at 7:21pm

Thanks Jay, that is exactly how I was going to do it... planned to post back here when I had.... many thanks!