Jump to:

1976 Posts in 1306 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Multilingual Form

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

Page: 1
Go to End
Author Topic: 916 Views
  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Multilingual Form Link to this post

    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

  • Gaster
    Avatar
    Community Member
    1 Post

    Re: Multilingual Form Link to this post

    You can use a form builder for creating such forms. As I know one of its versions has multilingual option

  • Devlin
    Avatar
    Community Member
    186 Posts

    Re: Multilingual Form Link to this post

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

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

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

    $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.

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Multilingual Form Link to this post

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

    916 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.