View Categories

How to Translate URL Coupon Text with WPML and Polylang

Translating URL coupon text lets you show a different message to each language on a multilingual store, so a coupon notice or landing-page line reads in the visitor’s own language. Coupons & Add to Cart by URL Links for WooCommerce ships a free shortcode, [alg_wc_url_coupons_translate], that shows or hides content based on the active WPML or Polylang language.

Before you start #

  • WooCommerce, active.
  • WPML or Polylang installed, so the site defines the current language.

The shortcode reads the active language from the ICL_LANGUAGE_CODE constant that WPML and Polylang define. If no multilingual plugin is active, the shortcode treats the visitor as “not in the listed languages”.

Two ways to use it #

You can pass the two language variants as attributes, or wrap each language’s content between shortcode tags.

1. Attribute form #

Give the languages, the text for those languages, and the fallback text for all other languages:

[alg_wc_url_coupons_translate lang="EN,DE" lang_text="Discount applied!" not_lang_text="Reduction appliquee !"]

Visitors browsing in English or German see the first message; everyone else sees the fallback.

2. Wrapping form #

Wrap the content for a set of languages, and use a second tag with not_lang for the rest:

[alg_wc_url_coupons_translate lang="EN,DE"]Discount applied![/alg_wc_url_coupons_translate]
[alg_wc_url_coupons_translate not_lang="EN,DE"]Reduction appliquee ![/alg_wc_url_coupons_translate]

Attributes #

Attribute What it does
lang Comma-separated language codes to match, for example EN,DE.
not_lang Comma-separated language codes to exclude (used in the wrapping form).
lang_text The text shown to the lang languages (attribute form).
not_lang_text The fallback text shown to all other languages (attribute form).

Language codes are matched case-insensitively, so en and EN both work.

Using it inside a coupon notice #

The Pro Custom notice and per-coupon notice fields run shortcodes, so you can drop the translate shortcode straight into a notice to make it multilingual. Combine it with the free [alg_wc_url_coupons_print_notices] shortcode on any landing page that does not show WooCommerce notices by default.

Troubleshooting #

  • Everyone sees the fallback text. Confirm WPML or Polylang is active, since the shortcode relies on the language constant they set.
  • Nothing shows for a language. Check the language codes in lang or not_lang match the codes your multilingual plugin uses.
  • The tags print as text. Make sure you are placing the shortcode where WordPress runs shortcodes, such as post or page content, not a plain-text widget that has shortcodes disabled.

Get more control #

This shortcode is free. Coupons & Add to Cart by URL Links for WooCommerce Pro adds custom per-coupon notices, per-coupon redirects, and add-to-cart coupons, so your multilingual messages can be tailored per coupon. See what Pro unlocks.