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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Upgrading SilverStripe /

Ask questions about upgrading SilverStripe to the latest version.

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

$SearchForm didn't translate to other languages


Go to End


3 Posts   2154 Views

Avatar
joelg

Community Member, 134 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, 134 Posts

11 May 2010 at 9:50pm

Ok, will do that in the future...