Jump to:

1160 Posts in 2632 Topics by 409 members

Upgrading SilverStripe

SilverStripe Forums » Upgrading SilverStripe » $SearchForm didn't translate to other languages

Ask questions about upgrading SilverStripe to the latest version.

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

Page: 1
Go to End
Author Topic: 1331 Views
  • joelg
    Avatar
    Community Member
    129 Posts

    $SearchForm didn't translate to other languages Link to this post

    Hi

    This might help somebody. After doing a FulltextSearchable::enable(); in _config.php I got the $SearchForm up and running in the blackcandy theme.

    However even though I've enabled i18n and translatable the word "Search" wasn't translated. I had a look into the sapphire folder and there is a file called: ContentControllerSearchExtension.php with a function called SearchForm. Inside this form the _t()-function hadn't been used and that caused the problem.

    Here is how the function looks after a few corrections that made it work:

    /**
        * Site search form
        */
       function SearchForm() {
          $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : _t('SearchForm.SEARCH', 'Search');
          $fields = new FieldSet(
             new TextField('Search', '', $searchText)
          );
          $actions = new FieldSet(
             new FormAction('results', _t('SearchForm.GO', 'Search'))
          );
          return new SearchForm($this->owner, 'SearchForm', $fields, $actions);
       }

    Joel

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: $SearchForm didn't translate to other languages Link to this post

    Fixed in r104596, that was an oversight on our part, sorry about that! In general, you have better chances of your patch being noticed if you put it up on open.silverstripe.org.

  • joelg
    Avatar
    Community Member
    129 Posts

    Re: $SearchForm didn't translate to other languages Link to this post

    Ok, will do that in the future...

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