To show the back button label in the visitor’s language, use the built-in translation options in Back Button Anywhere Widget for WordPress. These are free and work with multilingual plugins that set the standard ICL_LANGUAGE_CODE constant, such as WPML and Polylang.
Option 1: the translate shortcode #
[alg_back_button_translate] outputs different text depending on the active language. It has two forms.
Self-closing form #
Provide all three attributes: lang, lang_text, and not_lang_text.
[alg_back_button_translate lang="FR" lang_text="Retour" not_lang_text="Back"]
When the active language is French, this prints “Retour”; otherwise it prints “Back”.
Enclosing form #
Wrap the text between opening and closing tags. Use lang to show it only for a language, or not_lang to show it for everything except a list.
[alg_back_button_translate lang="FR"]Retour[/alg_back_button_translate]
[alg_back_button_translate lang="DE"]Zurück[/alg_back_button_translate]
[alg_back_button_translate not_lang="FR,DE"]Back[/alg_back_button_translate]
On a French page only “Retour” renders; on a German page only “Zurück”; on any other language only “Back”. You can list several codes, comma-separated.
Option 2: the lang attribute on the button shortcode #
The main [alg_back_button] shortcode accepts lang and not_lang_text. When the active language is not in lang, the label is replaced with not_lang_text.
[alg_back_button lang="FR" label="Retour" not_lang_text="Back"]
Combine the two #
Because [alg_back_button] runs shortcodes inside its label, you can nest the translate shortcode in the label to build a fully localized button:
[alg_back_button label='[alg_back_button_translate lang="FR" lang_text="Retour" not_lang_text="Back"]']
Attributes reference #
| Attribute | Used in | Effect |
|---|---|---|
lang |
both shortcodes | Language code(s) this text applies to. |
lang_text |
[alg_back_button_translate] |
Text shown when the language matches (self-closing form). |
not_lang_text |
both shortcodes | Text shown when the language does not match. |
not_lang |
[alg_back_button_translate] |
Language code(s) to exclude (enclosing form). |
Good to know #
- Language codes are matched case-insensitively, so
FRandfrbehave the same. - These options read the active language from
ICL_LANGUAGE_CODE. If no multilingual plugin sets it, the non-matching text is used. - The
fa(Font Awesome) attribute and thelanglabel swap cannot be combined in one[alg_back_button]. Use separate shortcodes if you need both an icon and a translated label.
Get more control #
Translation is free. Back Button Anywhere Widget for WordPress Pro adds menu placement, a floating button, and hide/show rules. See what Pro unlocks.