Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Multilanguage Site and Forms

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

Page: 1
Go to End
Author Topic: 831 Views
  • biapar
    Avatar
    Forum Moderator
    435 Posts

    [SOLVED] Multilanguage Site and Forms Link to this post

    Hi,

    I've done a multilanguage site and I made a form ( layout and class ) for italian lang, but I need the same form for eng lang...
    I wish to solve the problem of traslating data and label and redirect page ( after submit form ) to landing page under right language site...

    if ($flag_ricerca_ok==1)
    Director::redirect('disponibilita-en/');
    //Director::redirect('disponibilita-'.$lang.'/');
    //echo "Disponibile";
    else
    Director::redirect('no-disponibilita-en/');
    //Director::redirect($langSegment.'no-disponibilita-'.$lang.'/');
    //echo "No Dispo";
    }


    So:

    In Layout/HomePage.ss

    <% if Locale == "en_GB" %>
    <!-- Inglese Search Form -->
    $DisponibilitaStep1EN_Form
    <% end_if %>
    <% if Locale == "it_IT" %>
    $DisponibilitaStep1Form
    <% end_if %>


    and into Include dir , I've DisponibilitaStep1EN_Form.ss . The DisponibilitaStep1Form is rendered but other not when I'm in english site.

    Under my_site/code, I've create class :

    <?php
    class DisponibilitaStep1EN_Form extends Form {.....

    Thanks

  • Gelert
    Avatar
    Community Member
    8 Posts

    Re: [SOLVED] Multilanguage Site and Forms Link to this post

    I have the same problem, I'd be interested to see how to solve it.

    I have a Sidebar form which needs to direct English searches to one URL and when it the form is displayed in Italian it needs to direct submits to a different URL holding the Italian versions of the pages.

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: [SOLVED] Multilanguage Site and Forms Link to this post

    Solved.

    In my form class, I wrote:

    $language = Director::get_current_page()->Locale;
    $lang = substr($language, 0, 2);
          
    if ($lang == 'en')
    Director::redirect('availability/');
    else
    Director::redirect('disponibilita-'.$lang.'/');

    Bye

  • Gelert
    Avatar
    Community Member
    8 Posts

    Re: [SOLVED] Multilanguage Site and Forms Link to this post

    Thank you, that has solved my problem too.

    I altered the code slightly and put it on my custom form submit function:

    function submit($data, $form) {
       $language = Director::get_current_page()->Locale;

       switch ($language) {
          case "it_IT": $form_processor_url = "italianFormProcessor"; break;
          case "en_GB": $form_processor_url = "englishFormProcessor"; break;
          default: $form_processor_url = "englishFormProcessor"; break; // not needed, but just in case
       }

       Director::redirect(Director::baseURL(). $form_processor_url . "/?element1=".$somethingID);
    } // end func

    That's solved it. Now all I need to do is get the form front end working in Italian too! That bit shouldn't be so difficult.

    Thank you so much.

  • biapar
    Avatar
    Forum Moderator
    435 Posts
    831 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.