While extracting pot files from ecommerce modules, i've found some wrong usage of t() and form_plural() in cart.module, ecommailer.module, and product.module.
basically, there was t() functions calls instead of strings used in form_plural(), which is not correct as form_plural calls in turn t(). (http://drupaldocs.org/api/head/function/format_plural). and there was also php variables concatenated to strings in t(), instead of supplying them as parameter to the function, making a single translated string for each variable values.
patch is attached to correct the function calls.
additionnally, i also had errors in product.module, but they need to be discussed before fixing :)
some t() functions are called with an object value instead of strings, line 995 (there's also the same thing for a form_plural:
t($p->notification->subject, $variables), t($p->notification->body, $variables)
the $p->notification->subject/body should already be translated, if i'm not mistaken, as they are entered by the shop admin. so we could simply remove the t() call, but $variables is an array containing all values for subsitition (%site, %renewal_link, ...). i think the t() function call also handle the feature of replacing values in notification emails, so we cannot remove the t() calls without removing this, still if i'm not mistaken of course. but in that case, i don't really like the idea to use t() for this. but i'll look at it further.
the last issue if with a plural form in product.module at line 877, but i'll product a patch for solving it, as it leads to a lot of translation of already translated items, including passing a translated string to strtotime, so this has to be studied a bit more :)
thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | ec-4.6-translation-fix_0.patch | 7.17 KB | syllance |
| translation-fixes_0.patch | 3.98 KB | syllance |
Comments
Comment #1
sin commentedI also fixing plural forms in ecommerce for translation.
I found some incorrect (manual) plural formatting which was impossible to translate on my 3-plural form language without altering the code.
Here they are:
store.module: line 1258
was:
fixed:
cart.module: line 126
was:
fixed:
Please include my fixes to your patch, I am not familiar with cvs and diff :)
Comment #2
syllance commentedi'll double check and roll a patch with the fixes you sent. I've some more to add too, and needs to product a 4.6 patch, and a head patch.
this should be available very soon, and i'm moving this to code needs work until i finish the patches.
thanks
Comment #3
syllance commentedHere's the patch that fixes previously listed problems with t() and format_plural().
I've merged titmouse and my changes.
Note that I've modified calls to format_plural added by titmouse to use "%count " even for singular.
I've also fixed some issues with translating some submit buttons. Not all of the form_submit calls were using t() function to translate the buttons, and I also modified store_admin to handle translated terms in the case ($op) checks. I also fixed the Search feature wich was not working with my 4.6 sandbox ($op was check for 'Search', where it should be t('Search') when using translated submit buttons.
Please find the patch attached for 4.6 ecommerce, and let me know if that helps or breaks :)
i'm moving the thread to code need review. I'll create an alternate one for HEAD patch, which I'm still working on.
thanks for reading
Comment #4
matt westgate commentedCommitted. Thanks!
Comment #5
(not verified) commented