Can't translate "Thank you for shopping at [store:name]. While logged in, you may continue shopping or view your current order status and order history."

I solved this by doing:

uc_cart.module

-  $messages['completion_logged_in'] = t('Thank you for shopping at [store:name]. While logged in, you may continue shopping or <a href="[uc_order:url]">view your current order status</a> and order history.');
+  $messages['completion_logged_in'] = t('Thank you for shopping at [store:name]. While logged in, you may continue shopping or <a href="@uc_order">view your current order status</a> and order history.', array("@uc_order" => "[uc_order:url]"));

Comments

longwave’s picture

In 7.x-3.x-dev with the help of i18n and Variable modules you can now translate these messages directly in the admin page. This was changed in #1533286: Add support for Variable module

However we could still change the defaults here, so the messages can be translated by default. I wonder why the [store:name] token is okay here, when the [uc_order:url] one isn't? Or is it because of the double quotes?

zhongguo999999’s picture

Not because of the double quotes.
May be D7 core, I guess.
Because the error is that the submitted string contains disallowed HTML: %string.

longwave’s picture

Status: Active » Closed (duplicate)

There is a similar issue open for another string, let's deal with all tokenised strings in the same issue: #1535316: Can't translate "Return to the front page" or other strings containing links to tokens

zhongguo999999’s picture

In Version 7.x-3.3, I can't translate the string below:

t("Your order is almost complete. Please review the details below and click 'Submit order' if all the information is correct. You may use the 'Back' button to make changes to your order if necessary.");
t('Your order is complete! Your order number is [uc_order:order-number].');
t('Thank you for shopping at [store:name]. While logged in, you may continue shopping or view your current order status and order history.');
t("Thank you for shopping at [store:name]. Your current order has been attached to the account we found matching your e-mail address.\n\nLogin to view your current order status and order history. Remember to login when you make your next purchase for a faster checkout experience!", array('!user_url' => url('user')));
t("Thank you for shopping at [store:name]. A new account has been created for you here that you may use to view your current order status.\n\nLogin to your new account using the following information:\n\nUsername: !new_username\nPassword: !new_password", array('!user_url' => url('user')));
t("Thank you for shopping at [store:name]. A new account has been created for you here that you may use to view your current order status.\n\nYour password and further instructions have been sent to your e-mail address.\n\nFor your convenience, you are already logged in with your newly created account.");
t('Return to the front page.');

My solution:

function uc_cart_complete_sale($order, $login = FALSE) {
  global $user;
...
  foreach ($messages as $id => &$message) {
-   $message = variable_get($id, $message);
+		$message = t(variable_get($id, $message));
    $message = token_replace($message, array('uc_order' => $order));
    if ($id == 'uc_msg_order_' . $type) {
      $message = strtr($message, $variables);
    }
  }