-
Notifications
You must be signed in to change notification settings - Fork 67
Fix order email title & subject translations #414
Conversation
if you use the global WP locale of the site instead of the helper then the code will repeatedly unload and reload the text domain for every email string, even when the locale is already switched - this is a relatively slow and expensive operation. Do you have any other code which is impacting locale? Then possible pull requests should ideally be submitted as fixing issue # issue number |
1ccd14f
to
2950e65
Compare
Fixes introduced by 89ca15d added a clever comparison of the current locale with the order one to determine whether the content should be translated or not. get_locale helper is contextual and might not return the right locale. This commit uses the global WP locale of the site instead.
Now that emails fields are translated with the right locale, even the new_order_recipient setting must have a default value otherwise below code replace the address by null: ``` $string = __( $this->default_settings[ $email_type . '_' . $string_type, 'woocommerce' ); ```
Indentation was inconsistent following recent patches.
2950e65
to
ff178db
Compare
I created #415 & #416 to report properly my issues and the investigation/debug I did. I updated my code to take into account your feedback, now that I have a better understanding of the code. |
I'll merge this and add the default cancelled order and failed order recipient as per the new_order_recipient |
the default recipient is the shop email address so this should not be surrounded with the translation function __( , 'woocommerce') as it will not exist in the woocommerce translation files |
Hi @Jon007, @Annih and of course @hyyan, Thanks for all the amazing work. I kept having a translation issue with the emails in the heading and some parts of the mails like the topic. Even after implementing this commit. Finnaly I found one interesting fix that solved it for me. I had the setting in my user profile on 'Site Default', which is Dutch in my case. When I changed it to English (one of the 4 languages) the emails were translated correctly. Can you reproduce this? |
@frisonl I did some extra testing around the case you described and cannot reproduce, is working fine in test environment, are you sure it was not a caching or other issue. |
Fixes introduced by 89ca15d added a comparison of the current locale with the order one to determine whether the content should be translated or not.
Two variables have been introduced
$locale
based onget_locale
&$baseLocale
based onWPLANG
.Sadly
get_locale
helper is hookable and contextual and might not return the right locale.During my debugging session I ended up with an email title in one language and its subject in the other.
When I saw that the
$baseLocale
variable was present I decided to use the global WP locale of the site instead of the helper, and it fixed my issues.Since this is an edit of your code @Jon007 what do you think?
Fix #415
Fix #416