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.

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

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

$SearchForm didn't translate to other languages


Reply


3 Posts   1369 Views

Avatar
joelg

Community Member, 129 Posts

10 May 2010 at 8:49am

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

Avatar
Ingo

Forum Moderator, 801 Posts

11 May 2010 at 9:30pm

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.

Avatar
joelg

Community Member, 129 Posts

11 May 2010 at 9:50pm

Ok, will do that in the future...