Messages not translated when completing checkout

Project:Ubercart Contributions
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

Hi

I've found a translation missing when the message that finishes the checkout is shown. In the function uc_cart_complete_sale of uc_cart.module, the $show_message variable (line 1824 or so) is assigned this way:

$show_message = check_markup(variable_get('uc_msg_order_'. $message_type, uc_get_message('completion_'. $message_type)), variable_get('uc_msg_order_'. $message_type .'_format', 3), FALSE);

But the variable should be translated:

$show_message = check_markup(t(variable_get('uc_msg_order_'. $message_type, uc_get_message('completion_'. $message_type))), variable_get('uc_msg_order_'. $message_type .'_format', 3), FALSE);

Without the t call, the locale translation for checkout messages is not used and the translation is duplicated.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Messages not translated when completing checkout

Actually, according to the docs t() should only be used to wrap string literals, not actual variables. I know it's not ideal, but there are other ways to make sure variables get translated. I think one way is through the i18n module as reported by others, but I haven't done it myself. Another might be to make those messages in some form of PHP that could display a different messages depending on locale. I wouldn't recommend this for maintainability, tho.

pcambra's picture
Offline
Bug Finder
Joined: 01/23/2008
Juice: 251
Re: Re: Messages not translated when completing checkout
Assigned to:Ryan» pcambra

You are right Ryan, the translation of these variables using t() doesn't do what it should, the placeholders are not replaced Sad.

We are going to translate twice this strings as a quick solution.
I think that all the messages that ubercart generates should be handled by the drupal locate engine, but I am not sure how to change this.

Thanks!!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Messages not translated when completing checkout
Assigned to:pcambra» Ryan

It's really just going to take a large patch for D6... no easy way around it. It might work better if we made the default messages hardcoded in t() and still allowed some form-based overrides or something. Not too sure about that, tho...