Add extra check to handle formal and informal locales.#46
Conversation
The wp_locale in the translation_sets object do not contain the _formal or _informal part. For example: the wp_locale of Dutch (Formal) is nl_NL. The information that it's formal is only in the `slug` property. Because this->locale does have the _formal or _informal part, the comparison with the wp_locale had an incorrect result for informal and formal languages. This commit adds an extra check in which the slug is appended to the locale if the slug is not 'default' (i.e. is 'informal' or 'formal'). This string is compared to this->locale to make sure the correct $set is returned.
5c9609c to
5c14b40
Compare
|
Testing a bit this, there are 2 important steps to follow to test properly, otherwise you'll get unexpected results:
That said, I think the new check added in this PR should be within the foreach loop? Currently, it's outside of the loop so it always checks the last translation set returned by the api response, which is |
|
To delete the transient:
|
|
CR 👍 Also I acceptance tested. But will let someone else take a look at it as well. |
|
Code wise, 👍 However, because of... WordPress 🙂I'm not sure the actual behavior is what we'd want. Today I've learned that when switching language, WordPress downloads its own .mo/.po files but it doesn't downloads the .mo/.po files for plugins (and themes). Our I18n-module checks for Thus, after switching language To reproduce:
This happens with all languages: the wrong notification message is displayed until users update the translations and the .mo/.po files get actually downloaded. Dutch formal without .mo/.po files: Esperanto without .mo/.po files: Not sure why WordPress doesn't immediately downloads the plugins/themes translations, will ask upstream. From our side, in this scenario the messages that depends on |
|
Thanks to @swissspidy for shedding some light on the WordPress behavior. Looks like it always worked this way: changing language in Settings -> General doesn't handle plugin/theme language packs. This part should be addressed upstream. From our side we should probably change the notification messages because especially the I'd lean towards merging this PR because it's an improvement anyways and create a new issue. |




Changelog:
Technical choices:
The wp_locale in the translation_sets object do not contain the _formal or _informal part. For example: the wp_locale of Dutch (Formal) is nl_NL. The information that it's formal is only in the
slugproperty. Because this->locale does have the _formal or _informal part, the comparison with the wp_locale had an incorrect result for informal and formal languages. This commit adds an extra check in which the slug is appended to the locale if the slug is not 'default' (i.e. is 'informal' or 'formal'). This string is compared to this->locale to make sure the correct $set is returned.Test instructions:
On wordpress-seo trunk:
Deutsch (Sie).Copy the code changes from this PR to wordpress-seo's vendor > yoast > i18n-module > src > i18n-module.php.
Deutsch (Sie)) Go to SEO > General. See no translation-related notice.