Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Email translation issues #431

@Jon007

Description

@Jon007

There has been some confusion on this in merging different contributions to Emails.php.

There are two different concepts which need to be taken into account separately:

  • The current language at the time of code execution may not be the order language
  • The current language at the time of code execution may not be the WordPress Site Language

In fact, current language (eg preferred language of shop administrator), order language (language of customer) and Site Language could all be different.
There's also another language setting, the Polylang default language: though for translation purposes the site language is the correct one to use.

Combined with these possibilities, there may be a custom string set in woocommerce settings which may or may not have a translation in Polylang strings translation.

Issue 1: string set in WooCommerce settings and order is in base language
At the time of writing the code detects whether a translation exists in the Polylang strings translation table by testing whether the result of polylang string translation is the same as the input string, and if not, attempts to get a translation of the default string.

This is incorrect if the input string is already in the correct language and results in a string customised in WooCommerce settings being replaced with the default string in the base language.

Instead, if order language == site base language == current language then code should return the input directly without attempting any further language processing.

Issue 2: common strings when sending from order admin
Common strings such as footer text, from name, from email (which do not receive an order parameter) are processed in whatever the current language happens to be, whereas it is possible to detect the order screen and correctly use the order language.

Issue 3: default settings not loaded in correct language
The default settings for language file translation need to be the actual woocommerce source code language to work when using as translation source to look up translation in another language.
This may fail for emails sent from order admin if site admin is running a language other than english or site base language is not english.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions