Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Without using Better Exposed Filters the translations for the 'Apply' and 'Reset' buttons work as expected by translating the strings using Translate interface. However if I select BEF for the form style the strings are not translated, the original string is displayed in all language versions of the site.
Comments
Comment #2
vimokkhadipa CreditAttribution: vimokkhadipa commentedI have the same problem.
Comment #3
Baher CreditAttribution: Baher commentedI have the same problem with button and the exposed field label
Comment #4
Baher CreditAttribution: Baher commentedThe same thing for me
Comment #5
DeonEmyr CreditAttribution: DeonEmyr as a volunteer commentedSame issue for me too.
Comment #6
tsaks CreditAttribution: tsaks commentedSame issue.
Comment #7
ezoulou CreditAttribution: ezoulou commentedsame here
Comment #8
francoisb CreditAttribution: francoisb commentedI fixed this issue with PHP code, by implementing
hook_form_alter()
in a custom module:… where
mymodule
must be replaced by your module name.Comment #9
kamenrs CreditAttribution: kamenrs commentedI have the same issue, not only with Submit and Reset buttons, but also with the Secondary options label in BEF settings.
Is this bugfix going to be implemented in a dev or new version of the module?
Thanks.
Comment #10
mikeker CreditAttribution: mikeker as a volunteer commentedSorry, my (limited) time right now is focused on getting an 8.x release out the door. I'm happy to commit quality patches that reviewed by the community in the 7.x branch. But until I have more time (or sponsorship) I can't put much effort into this branch.
Comment #11
Yannick PerretThanks to @francoisb for its workaround. Two notes:
$form['reset']['#value'] = t($form['reset']['#value']);
to also handle the reset buttonComment #12
francoisb CreditAttribution: francoisb commented@yannick-perret
'reset'
is needed provided that the Reset button is actually displayed on the form. Settings allow for not displaying it, which is the case on my site. Code needs to first check presence of key$form['reset']
, then do the translation.Comment #13
Yannick PerretI got an other problem: when translated, 'reset' button don't works anymore. The problem comes from 'views' code as far as I can see.
In views/plugins/views_plugin_exposed_form.inc (lien 296) reset is detected with
$form_state['values']['op'] == $this->options['reset_button_label']
. But when button label is translated, and because submit type in Drupal don't has a label part, here$form_state['values']['op']
contains the translated label but$this->options['reset_button_label']
contains the untranslated value. So it don't works.I solved all by reset button problems (translation and working properly) by this two changes in views/plugins/views_plugin_exposed_form.inc:
The first change ensure that the reset button is added with the translated label. The second change compares the 'value' part of the 'op' (which is translated) to the translated value of reset.
Of course I guess the same changes should be applied to submit button.
Some feedback? Do I need to submit an issue to 'views' module?
Comment #14
francoisb CreditAttribution: francoisb commented@yannick-perret Yes, please. If your fix improves the views module, file issue there. Here you can suggest changes only for Better Exposed Filters.
Comment #15
Yannick PerretOk, I will do.
By the way I have a related issue with a very simple workaround for BEF: when replacing the "- Any -" label from BEF it is also not translated (and it is without BEF).
Comparing both codes seems to point to line 1728 in better_exposed_filters/better_exposed_filters_exposed_form_plugin.inc:
At least this works for me.
I don't know if other cases are concerned (this is the only one I use).
I'm using BEF version 7.x-3.5 (datestamp = 1508952850).
Comment #16
Neslee Canil PintoHi, there will be no more future development for 7.x branch. If you see this issue in 8.x, feel free to file an issue. Closing this as Closed(wont fix).