The Review order and Submit order buttons on the checkout pages are not translatable due to the string not being passed correctly to t() (unless this is by design?).

The reason is that only the default value of variable_get() is being run through t() whereas the string loaded from the variables table isn't. This patch fixes this by running the whole variable_get() through t().

Comments

cha0s’s picture

Good call. There are probably more of these around, and they should be fixed... I'll start a patch if the other devs agree.

rszrama’s picture

Status: Needs review » Needs work

Hmm... so, I feel you on this patch, but this solution actually won't work. You can only pass string literals through t(), so the solution should actually be something more like what I'm doing for the shopping cart block title. To be honest, what if we just took out the ability to rename these buttons? I don't think it's essential, and people who really want to have viable alternatives through the Local/String Overrides modules or through a simple hook_form_alter(). Whaddya think?

cha0s’s picture

Yeah, I think there would be a way for someone to create their own 'translation' of the strings we use for stuff like that, even if it isn't truly another language, that'd work I think. We should probably just let that system do its thing... Yeah, hook_form_alter's a bit simpler as well if people choose to go that route. =)

rszrama’s picture

Assigned: Unassigned » rszrama
Status: Needs work » Fixed
Issue tags: +i18n
StatusFileSize
new5.69 KB

Alrighty, I removed the options for review, submit, and next buttons in the cart module. The attached patch takes care of it. It's been tested on the 2.x Livetest and will be included in the next release. I'm updating the docs to instruct people how to tweak this text from here on out.

ARray’s picture

Will it be fixed for cart block?
"View cart" and "Checkout" links are not translatable now in cart block. :(

ARray’s picture

I guess there should be added t() in uc_cart.module:
[code]
$summary_links = array(
'cart-block-view-cart' => array(
'title' => t('View cart'), // surrounded by t() here
'href' => 'cart',
'attributes' => array('rel' => 'nofollow'),
),
);
// Only add the checkout link if checkout is enabled.
if (variable_get('uc_checkout_enabled', TRUE)) {
$summary_links['cart-block-checkout'] = array(
'title' => t('Checkout'), // surrounded by t() here
'href' => 'cart/checkout',
'attributes' => array('rel' => 'nofollow'),
);
}

[/code]

rszrama’s picture

You've tested and these aren't translatable? Based on the source for that theme function, it was hard to tell whether my links arrays should be using t() or not.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

marcoBauli’s picture

Status: Closed (fixed) » Active

sorry for reopening this, but seems also the "Submit order" button on product node page cannot be translated...

i am using string_override module, that is able to translate whatever appears between t()s.

i had a deep look at all the components, but couldn't find where that string is.. can anyone confirm this is happening and eventually lend a hand?

thanks a lot

rszrama’s picture

Assigned: rszrama » Unassigned
Status: Active » Closed (fixed)

I think it would be best to post your request as a support request on Ubercart.org. This ticket was unrelated.

MakeOnlineShop’s picture

Hi,

Sorry but did you find a solution to translate Submit Order on Ubercart ? I have been trying to find a solution for hours...

Thanks a lot.

jejk’s picture

Check also the payment method modules such as the paypal one which creates its own review form

MakeOnlineShop’s picture

When customers pay with Paypal the "Submit order" is there:

/admin/store/settings/payment/edit/methods

But where is it when they use another payment ?

Thanks.

graham leach’s picture

Hello,

It seems to me that Ubercart 2.x on Drupal 6.x (D6U2) has serious legacy UX issues.

I recently spent hours trying to accomplish the translation of elements of the Checkout and Checkout Review screens. The buttons Review Order, Back and Submit Order needed different treatment to accomplish a complete translation exercise. Here's how I did it:

Via Code?
The code in modules/ubercart/uc_cart/uc_cart.pages.inc (around line 484) features the following, which I have added a couple of explanatory comments to, to help with comprehension:

/**
 * Gives customers the option to finish checkout or go revise their information.
 *
 * @see uc_cart_checkout_review_form_back()
 * @see uc_cart_checkout_review_form_submit()
 * @ingroup forms
 */
function uc_cart_checkout_review_form() {
  // Set the session variable to pass the redirect check on the pageload.
  if (isset($_POST['op']) && $_POST['op'] == t('Back')) {
    $_SESSION['do_review'] = TRUE;
  }

/* ----------------------------------------------------------------------- */
/*                                                                         */
/* GL    2017-03-07    This is the text that is placed on the LEFT         */
/*                     (Back) button on the order review form              */
/*                                                                         */
/* ----------------------------------------------------------------------- */
   $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('Back'),
    '#submit' => array('uc_cart_checkout_review_form_back'),
  );

/* ----------------------------------------------------------------------- */
/*                                                                         */
/* GL    2017-03-07    This is the text that is placed on the RIGHT        */
/*                     (Submit order) button on the order review form      */
/*                     The #value setting is ignored by Ubercart, and      */
/*                     Translate Interface as well                         */
/*                                                                         */
/*                     Go to:  /admin/store/settings/payment/edit/methods  */
/*                     Expand: PayPal Website Payments Standard settings   */
/*                     Open:   Order review submit button text             */
/*                                                                         */
/* ------------------------------------------------------------------------*/
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit order'),
    '#submit' => array('uc_cart_checkout_review_form_submit'),
  );

  return $form;
}

Unfortunately, changing the value of Submit order in the above code has zero effect on the behavior of the Checkout Review Page (/cart/checkout/review). This somewhat inexplicable phenomena led to me having to mess around in the Ubercart 2.x code and administration interface for hours until I figured out what was going on.

Via the Translate Interface?
The Translate Interface (/admin/build/translate/search) is a powerful tool when it comes to developing multi-lingual websites. This is where the text for the Review Order button located at the first Checkout screen (/cart/checkout) and the Back button located at the Checkout Review screen (/cart/checkout/review) were both made to dynamically change when different languages were selected.

So, I was able to translate Review Order and Back using the Translate Interface. But, no matter how I tried, the Submit Order button refused to translate, despite the fact that it seems to be a translateable string. This is indicated by the t in the following code snippet:

'#value' => t('Submit order'),

As it turns out, the button text for Submit order cannot be translated using the Translate Interface function, even though the variable in question is bounded by the translate function (t), a real wild goose chase.

Via the Ubercart Store Administration Interface?
After a lot of set-test cycles, I turned to the Internet and this is where I found some clues. In one posting, someone mentioned that the string for the Submit Order appeared in the Ubercart administration extension to the Drupal administration interface. I eventually found the setting here:

Home » Dashboard » Store administration » Configuration » Payment settings » Payment Methods » PayPal Website Payment Standard Settings » Order review submit button text

This posting, or another temporally proximate to it, mentioned that the field was translatable, which is indicated by the field having the notation This is a multilingual variable appear beneath it. To translate these fields, the user interface must be switched to the target language (I clicked on the icon for the language I wanted to translate to from the English interface) and the fields magically changed to the target language - but NOT the string in question, which appeared in English! To change it, I needed to replace the English field contents with the necessary translation, and the final piece of the checkout process fell into place, and the checkout-related buttons that were so much trouble before now behave as desired.

tr’s picture

Issue summary: View changes

Drupal 6 and Ubercart 2.x have been unsupported for more than a year now. If you have problems with the current versions of Ubercart (7.x-3.x or 8.x-4.x) please open a new issue.