• Hello MultilingualPress team

    Thank you for a great plugin! I’ve used it for many years and never ran into a bug, this is the first time I do.

    In the latest version there is a bug in WooCommerce product category archive pages.

    Summary:

    • On normal WordPress pages and single product pages, the site locale is correct.
    • On WooCommerce product category archive pages only, the locale sometimes ends up wrong.
    • In our case, the Finnish site starts rendering German strings on product category archives, for example:
      • WooCommerce sorting labels
      • stock/status labels
      • Astra shop loop stock badge text
    • Disabling MultilingualPress immediately makes the problem disappear.
    • The issue is not theme-specific. I tested with another theme as well and the same archive-only locale problem remained.

    What I observed:

    • The current site/blog is correct.
    • The category itself is also assigned to the correct Finnish site.
    • The problem appears only in the archive context, not on product pages or regular pages.
    • It looks like MultilingualPress is switching site/locale during archive translation handling and not restoring it correctly for product_cat archive requests.

    Relevant MultilingualPress code paths:

    • src/framework/WordpressContext.php
    • src/framework/SwitchSiteTrait.php
    • src/multilingualpress/Translator/TermTranslator.php

    The important behavior seems to be:

    • WordPressContext classifies category/taxonomy requests as term archives.
    • TermTranslator::translationFor() switches to the remote site.
    • SwitchSiteTrait::updateLocaleToMatchSite() calls switch_to_locale($siteLocale).
    • On product category archives, that locale appears to leak into the rest of the request, so WooCommerce labels are rendered in the wrong language.

    Workaround that fixed it for us:

    • We added a small theme-level workaround that forces the correct locale on is_product_category() requests.
    • With that workaround in place, the issue disappears immediately.

    So I think the bug is specifically in the term/archive locale switching flow for WooCommerce product category archives. It also happens with different themes and different sites.

    Thanks.

You must be logged in to reply to this topic.