The "Out of stock" message would not translate even though the translation is created.
I think I found where the issue comes from : the javascript module (uc_out_of_stock.js, line 93) is not receiving the right string from the PHP module (uc_out_of_stock.module line 34).
uc_out_of_stock.js, line 93
// Show out of stock message
$(".uc_out_of_stock_html", form).html(Drupal.settings.uc_out_of_stock.msg);
I spotted that the issue comes from uc_out_of_stock.module line 34
$settings_js['uc_out_of_stock']['msg'] = check_markup(variable_get('uc_out_of_stock_text', UC_OUT_OF_STOCK_DEFAULT_HTML), variable_get('uc_out_of_stock_format', FILTER_FORMAT_DEFAULT), FALSE);
It works when adding t() at the right place like here :
$settings_js['uc_out_of_stock']['msg'] = check_markup(t(variable_get('uc_out_of_stock_text', UC_OUT_OF_STOCK_DEFAULT_HTML)), variable_get('uc_out_of_stock_format', FILTER_FORMAT_DEFAULT), FALSE);
So basically :
check_markup(t(...), ..., ...);
This is my first contribution to Drupal. So I might not have formatted my post correctly. Please advise me if necessary.
Comments
Comment #1
hanoiiBecause that message is a a configurable string, it should not really be embedded between t() as that's for hardcoded strings.
What you should do, is use i18n module which has a i18n variable module that let's you translate configuration variables (let you add a configuration per language). This module supports that so the setting page of the module should allow you to configure any language of the message.
If you happen to do this, would you mind creating a documentation entry about it? You can paste it here and I will move it to the project page, README or a documentation entry on the handbook.
Comment #2
FranckV commentedI personally don't like i18n Variables : they oblige you to go to so many different places for the translations and you need to keep switching to the various languages to be able to write and save the translations.
Using t() allows a centralized translation form where you can generate several translations for a given message in a go. It is also better supported by some nice translation helper modules.
However I saw you indeed tried to use i18n Variables in your code and observed that it would not work.
Shall I suggest you change line 12 of uc_out_of_stock_boot.module...
from :
function uc_out_of_stock_init(){to :
function uc_out_of_stock_boot(){(Thanks to : http://drupal.org/node/313272#comment-3315478)
For me it works.
That leads me to a quick piece of documentation "how to translate uc_out_of_stock / internationalization of uc_out_of_stock" :
1- Go to the uc_out_of_stock settings page (...admin/store/settings/uc_out_of_stock).
2- Switch to a given language
3- Write the corresponding translation for the language you have just switched to
4- and save.
5- Switch back and forth to the available languages to check all translations are OK
Please be so kind to confirm this works on your side as well.
Cheers
Comment #3
hanoiiThanks, committed: http://drupalcode.org/project/uc_out_of_stock.git/commit/df5d7ab, I am not able to test it right now, but I saw that comment and if you have tried it, then that's ok for me.
Comment #3.0
hanoiiJust correcting and reformatting my message better