Closed (fixed)
Project:
Better Exposed Filters
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 Jul 2012 at 19:21 UTC
Updated:
27 Mar 2015 at 13:21 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
naiara commentedI've managed to do that by replacing line 428 in better_exposed_filters_exposed_form_plugin.inc:
$rewrite[$search] = $replace;with:
$rewrite[$search] = t($replace);But it takes always English as default language, so you have to specify the text for the replacement in english and then translate it to the language you want.
I guess it's easy to fix by passing more arguments to the t() function, however, this did the trick for me.
Comment #2
geek-merlinSame problem with filter options, i dare to extend the issue as both are oneliners.
Comment #3
geek-merlinPatch flying in that fixes both translations.
@others: please test and set issue status to rtbc, so we can get this in.
Comment #4
mikeker commentedThis seems like a good idea, and I want BEF to be as I18N-friendly as possible, but I'm have some concerned about using t() on variables. The API docs warn against translating variables "unless the text that the variable holds has been passed through t() elsewhere."
Major caveat: I have essentially zero experience with I18N sites. To those that do: please educate me! :)
Comment #5
berliner commentedThis is my approach on this topic. The attached patch is only for the overridden sort options but should be expandable easily.
It uses i18n_string_translate() to translate a variable ($combine_rewrite) that is exposed using hook_i18n_string_info().
For a german example, the original options array could look like this:
The german translation of the variable should then be entered likes this:
For more information on translation of user entered strings see:
Translating user-defined strings
Using the i18n API from other modules
Comment #6
mikeker commentedThanks for the patch and the example of how i18n functionality works. Much appreciated!
These seems unrelated to the issue at hand.
Comment #7
berliner commentedRight, my bad. I have removed the unrelated lines and updated the patch.
Comment #8
mikeker commentedMy apologies for the delay getting back to this issue. Thank you for the updated patch @berliner, it's been committed.
As mentioned in #5, this only works for exposed sort rewrites. I'll add an issue to continue this work for other parts of the BEF settings form. Regardless, this is a great start.
Comment #9
mikeker commentedComment #11
mikeker commentedComment #12
mikeker commentedA word of warning to those using this functionality: The code from this issue has largely been removed in favor of the approach in #2185077: Allow translations for all BEF settings. That fix allows all BEF settings strings to be translated without the dependency on the i18n_strings and i18n modules. This is not a reflection on the work done in this issue -- I appreciate your contributions! -- I feel fewer dependencies is better.
This means that translations for exposed sort rewrite options using the i18n_strings will no longer work in newer versions of BEF. I will be rolling out a new release of BEF in a few days. Please use care when updating your code!
I've started a handbook page outlining directions for translating BEF settings. Please feel free to edit/update it as needed.