Is there any way to translate replacement_value in in advanced sort options, when you select "Combine sort order with sort by" ?

Comments

I'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.

Title:Translate replacement_value in sort optionsTranslate replacement_value in sort options and in filter options

Same problem with filter options, i dare to extend the issue as both are oneliners.

Status:Active» Needs review
StatusFileSize
new1.48 KB
Test request sent.
[ View ]

Patch flying in that fixes both translations.

@others: please test and set issue status to rtbc, so we can get this in.

Status:Needs review» Needs work

This 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! :)

Status:Needs work» Needs review
StatusFileSize
new5.14 KB
Test request sent.
[ View ]

This 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:

[created ASC] => Beitragsdatum Aufsteigend
[created DESC] => Beitragsdatum Absteigend
[field_price_value ASC] => Preis Aufsteigend
[field_price_value DESC] => Preis Absteigend

The german translation of the variable should then be entered likes this:

[Beitragsdatum Absteigend] => Neue zuerst
[Beitragsdatum Aufsteigend] => Älteste zuerst
[Price Aufsteigend] => Niedriger Preis
[Price Absteigend] => Hoher Preis

For more information on translation of user entered strings see:
Translating user-defined strings
Using the i18n API from other modules

Status:Needs review» Needs work

Thanks for the patch and the example of how i18n functionality works. Much appreciated!

+++ b/better_exposed_filters_exposed_form_plugin.inc
@@ -936,7 +948,6 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
-          $bef_add_js = TRUE;

+++ b/better_exposed_filters_exposed_form_plugin.inc
@@ -1084,7 +1095,6 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
-          $bef_add_js = TRUE;

+++ b/better_exposed_filters_exposed_form_plugin.inc
@@ -1102,6 +1112,7 @@ Title Desc|Z -> A</pre> Leave the replacement value blank to remove an option al
+          $bef_add_js = TRUE;

These seems unrelated to the issue at hand.

Status:Needs work» Needs review
StatusFileSize
new3.92 KB
Test request sent.
[ View ]

Right, my bad. I have removed the unrelated lines and updated the patch.

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

Issue summary:View changes
Status:Needs review» Fixed

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.