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.
The following two strings:
- "Shipping quotes are generated automatically when you enter your address and may be updated manually with the button below." (part of uc_quote)
- "Your billing information must match the billing address for the credit card entered below or we will be unable to process your payment." (part of uc_credit)
Cannot be translated and are always displayed in English, despite having the appropriate variable names appended to $conf['i18n_variables'] in hook_init(). Translating the strings via "Translate Interface" has no effect, and the usual "This is a multi-lingual variable" text that typically appears on text entries in the store configuration does not appear.
In i18n/i18n.module, the following check is performed in i18n_form_alter():
if (isset($form['#theme']) && $form['#theme'] == 'system_settings_form' && $variables = variable_get('i18n_variables', 0)) {
It seems that because the $form['#theme'] is not "system_settings_form" for these two forms, they don't get blessed by i18n.
Comment | File | Size | Author |
---|---|---|---|
#3 | shipping_quote_messages_translation.patch | 2.02 KB | nick.dap |
Comments
Comment #1
stewart.adam CreditAttribution: stewart.adam commentedSorry, not sure what is going on here. This wasn't working for days, and suddenly it started working today (maybe caching issues on my side?).
Either way, the multi-lingual variables feature is working correctly however the above post is still correct in saying that the "This is a multi-lingual variable" text is not added to the text field descriptions.
Comment #2
krabbe CreditAttribution: krabbe commentedSame problem here. I translated the strings via "Translate Interface" but the German translation doesn't show up on checkout page.
So, I can hope, this issue will fix itself?
Comment #3
nick.dap CreditAttribution: nick.dap commentedFound the problem. If the descriptions and message were loaded from config, they weren't translated.
Comment #5
TR CreditAttribution: TR commented@nick.dap: No. That patch is just wrong. You can't use t() like that. Read the API documentation for t() to understand why.
The problem here seems to be that the i18n module insists that multilingual variables should only be defined by a system_settings_form(). This is an incorrect assumption, and should be corrected in the i18n module.
Comment #6
nick.dap CreditAttribution: nick.dap commentedDidn't know that, sorry. To be honest, I've read the doc page and still don't understand what's wrong with this. Would you please explain?
It seems that the string can be either "default" or w.e is defined in the admin page. You take either one and pass it through the translate function. Why is that wrong? Why is passing the default ok and passing the defined not ok? This is not content per-se and is analogous to passing the "description" of a form field through t(), which is done all the time it seems.
Comment #7
stewart.adam CreditAttribution: stewart.adam commented> Didn't know that, sorry. To be honest, I've read the doc page and still don't understand what's wrong with this. Would you please explain?
The problem here is that t() should never be used to translate a variable. Instead, fix the problem at source - the variable itself. In this case, we should not pass the stored value of uc_quote_pane_description through t() but instead fix the problem in i18n so that uc_quote_pane_description can be translated properly.
Comment #8
PieterDCI agree with TR and firewing1, but it was faster for me to patch the Ubercart Quote module than patching i18n.
So, if you're looking for a partial solution, see #1257488: Make shipping quote pane description and error message really translatable
Comment #9
PieterDCI didn't mean to change the 'Component' of this issue, but apparently 'Code' disappeared from that list.
Now choosing 'Compatibility' as we'd like that to happen with variables not edited through a system_settings form.
Comment #10
joseph.olstad