Preserve language in WooCommerce background work

Scheduled renewals, delayed notifications, asynchronous imports, and other background tasks do not have a visitor URL from which to infer a language. They must carry an order, customer, or explicit locale context.

Order-based work

For an order or subscription-related email, POM Translate resolves the stored order locale first. New classic and Store API orders preserve the active locale at checkout, so a later task can render customer content in the purchase language.

Older orders fall back through the customer locale, current POM locale, and base locale. For predictable background output, populate the order context rather than depending on whatever locale happens to be active in cron.

Custom background integrations

A supported integration should:

  1. Load the order or customer that owns the operation.
  2. Resolve an enabled locale.
  3. Run only the rendering callback inside pom_translate_with_locale().
  4. Translate stable pre-merge templates.
  5. Insert dynamic customer and order data afterwards.
  6. Let the locale wrapper restore the previous state.

Do not set a global locale and leave it active for the rest of a queue worker. Do not register rendered messages containing customer or order data.

Catalog synchronization

Trusted product and taxonomy saves performed by imports, CLI commands, or scheduled synchronization can refresh POM Translate source strings without a logged-in administrator. The importer should still use normal WordPress and WooCommerce persistence APIs.

After a large synchronization, inspect pending translations for changed product or term copy. Source updates can require review even when product IDs remain unchanged.

Verify

Run one background operation for two orders with different stored locales in the same worker or cron cycle. Confirm:

  • each output uses its own order locale;
  • product and metadata labels are translated correctly;
  • no locale leaks into the next job;
  • customer-specific text is not added to the registered-string list;
  • retries do not create duplicate emails or orders.

For scheduled extension emails, also review Subscriptions and follow-up email.