diff --git a/uc_order/templates/uc_order-admin.tpl.php b/uc_order/templates/uc_order-admin.tpl.php index 0d10c3f..9675c96 100644 --- a/uc_order/templates/uc_order-admin.tpl.php +++ b/uc_order/templates/uc_order-admin.tpl.php @@ -7,14 +7,14 @@ ?>

-
- -
-
- +
+ -
+
+

-
+
'themed', @@ -31,10 +31,10 @@ foreach ($products as $product) { $context['subject']['order_product'] = $product; ?> - qty; ?> x title .' - '. uc_price($price_info, $context); ?>
-  model; ?>
+  model; ?>
data['attributes']) && is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {?> data['attributes'] as $attribute => $option) { - echo '  '. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))) .'
'; + echo '  '. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option)), $langcode) .'
'; } ?>
@@ -42,6 +42,6 @@ foreach ($products as $product) {

-
+

diff --git a/uc_order/templates/uc_order-customer.tpl.php b/uc_order/templates/uc_order-customer.tpl.php index c052642..4756050 100644 --- a/uc_order/templates/uc_order-customer.tpl.php +++ b/uc_order/templates/uc_order-customer.tpl.php @@ -37,15 +37,15 @@ -

$order_first_name)); ?>

+

$order_first_name), $langcode); ?>

-

-


-

+

+


+

-


+


$store_link)); ?>

@@ -53,12 +53,12 @@
- +
- + @@ -70,18 +70,18 @@ @@ -92,7 +92,7 @@ @@ -127,7 +127,7 @@
-
+


-
+

-
+


-
+

- + @@ -100,7 +100,7 @@
- + @@ -109,14 +109,14 @@
- +
- +
- + @@ -136,7 +136,7 @@
- + @@ -146,7 +146,7 @@
- + @@ -156,7 +156,7 @@
-   +   @@ -197,7 +197,7 @@
-   +   @@ -206,7 +206,7 @@
-

  +

  @@ -234,10 +234,10 @@ title .' - '. uc_price($price_info, $context); ?>qty > 1) { $price_info['qty'] = 1; - echo t('(!price each)', array('!price' => uc_price($price_info, $context))); + echo t('(!price each)', array('!price' => uc_price($price_info, $context)), $langcode); } ?>
- model; ?>
+ model; ?>
data['attributes']) && is_array($product->data['attributes']) && count($product->data['attributes']) > 0) {?> data['attributes'] as $attribute => $option) { echo '
  • '. t('@attribute: @options', array('@attribute' => $attribute, '@options' => implode(', ', (array)$option))) .'
  • '; @@ -263,15 +263,15 @@

    -


    +


    help page.', array('!store_link' => $store_link, '!store_help_url' => $store_help_url)); ?>

    -

    +

    -

    +

    diff --git a/uc_order/uc_order.ca.inc b/uc_order/uc_order.ca.inc index 7ce5aa0..a2e2ae9 100644 --- a/uc_order/uc_order.ca.inc +++ b/uc_order/uc_order.ca.inc @@ -1259,15 +1259,37 @@ function uc_order_action_email_invoice($order, $settings) { $recipients[] = trim($address); } - $settings['message'] = theme('uc_order', $order, $settings['view'], $settings['template']); - if (empty($recipients)) { watchdog('ca', 'Attempted to e-mail an invoice with no recipient.', array(), WATCHDOG_ERROR); return; } + + // Determine which languages we will need to generate the invoice template for + $languages = array(); + foreach ($recipients as $email) { + $preferred = uc_store_mail_recipient_language($email); + $langcode = $preferred->language; + if (!in_array($langcode, $languages)) { + $languages[] = $langcode; + } + } + + // Generate the template and store it to avoid generating a template for the same language twice + // We provide the extra argument $langcode to theme() so that the templates can use it + $message_translations = array(); + $subject_translations = array(); + foreach ($languages as $langcode) { + $subject_translations[$langcode] = t($settings['subject'], array(), $langcode); + $message_translations[$langcode] = theme('uc_order', $order, $settings['view'], $settings['template'], $langcode); + } + // Fire them off foreach ($recipients as $email) { - $sent = drupal_mail('uc_order', 'action-mail', $email, uc_store_mail_recipient_language($email), $settings, empty($settings['from']) ? uc_store_email_from() : $settings['from']); + $preferred_language = uc_store_mail_recipient_language($email); + $settings['subject'] = $subject_translations[$preferred_language->language]; + $settings['message'] = $message_translations[$preferred_language->language]; + + $sent = drupal_mail('uc_order', 'action-mail', $email, $preferred_language, $settings, empty($settings['from']) ? uc_store_email_from() : $settings['from']); if (!$sent['result']) { watchdog('ca', 'Attempt to e-mail invoice for order @order_id to @email failed.', array('@email' => $email, '@order_id' => $order->order_id), WATCHDOG_ERROR); diff --git a/uc_order/uc_order.module b/uc_order/uc_order.module index 2c5a71b..b433a03 100644 --- a/uc_order/uc_order.module +++ b/uc_order/uc_order.module @@ -323,6 +323,7 @@ function uc_order_theme() { 'order' => NULL, 'op' => 'view', 'template' => 'customer', + 'langcode' => NULL, 'thank_you_message' => FALSE, 'help_text' => FALSE, 'email_text' => FALSE,