Using the Portal with WPML
WC Account Portal works with WPML out of the box: the portal follows the visitor’s current language, mirrors itself for RTL languages, signs customers out to the home page of their language, and registers your own texts with WPML String Translation. You can translate those texts in WPML or in the plugin’s own language panels, whichever fits your workflow.
What happens automatically#
With WPML active, you do not need to set anything:
| What | How it works |
|---|---|
| Plugin text | The plugin’s translation file is loaded for WPML’s current language (using the wpml_locale filter), after WPML has switched the language. Menu names, buttons and the login page show in the visitor’s language. |
| Language detection | The current and default language come from the wpml_current_language and wpml_default_language filters. |
| RTL | When the current language code is ar, he, fa, ur, yi, ps, sd, ku, ckb or dv, the portal switches to right-to-left. |
| Language buttons in the settings | The languages on Content & Text, Translations and Pages come from WPML’s active languages (wpml_active_languages), without the default language. |
| Sign out | In a language other than the default, the sign-out link is /{language}/logout/ (for example /fr/logout/). After signing out, the customer goes to the home page of that language (wpml_home_url). In the default language the link is /logout/. |
Texts registered with WPML String Translation#
The plugin registers your own texts with WPML String Translation (wpml_register_single_string), in the domain wc-account-portal. You need the WPML String Translation add-on for this part.
Settings texts#
| WPML string name | Field in the plugin |
|---|---|
setting_portal_page_title | Portal Page Title |
setting_welcome_title | Welcome Title |
setting_welcome_message | Welcome Message |
setting_auth_tagline | Auth Page Tagline |
setting_announcement_text | Announcement |
setting_dash_help_title | Dashboard > Help & contact > Title |
setting_dash_help_text | Dashboard > Help & contact > Message |
setting_dash_help_link_label | Dashboard > Help & contact > Link text |
setting_dash_custom_title | Dashboard > Custom content > Title |
setting_dash_custom_content | Dashboard > Custom content > Content |
All ten are registered when you save Content & Text, except the ones that are empty: an empty text has nothing to translate, so it is not added to WPML’s list. Fill in the field and save again to register it. The five Dashboard texts are also registered when you save the Dashboard tab.
Menu labels#
Every account menu item with a label is registered as menu_label_{item id} when you save Menu Items, for example menu_label_orders, menu_label_downloads or menu_label_edit-address.
What is not registered#
- The Portal UI Strings (the “Back to [site]” link, Sign out, Light mode, Dark mode): they come from the plugin’s translation files, or from the Translations tab.
- Your own account pages from the Pages tab: translate their title and content on the Pages tab with the language buttons.
- Any other setting (colours, links, email and phone in Help & contact).
Translate in WPML String Translation#
- With WPML and WPML String Translation active, save each of these tabs once: WooCommerce > Account Portal > Content & Text, Dashboard and Menu Items. Saving is what registers the strings, so do this again after you install WPML on a site that already has a setup.
- Go to WPML > String Translation.
- In Select strings within domain, choose wc-account-portal.
- Click the translate button next to a string, type the translation for each language and save it.
- Open your account page in that language to check.
The plugin’s own translation wins. If a field for that language is filled on Content & Text or Translations (also by Fill in built-in translations), the portal shows that and not WPML’s. To use WPML String Translation for a text, leave the plugin’s field for that language empty.
The order the portal checks, per text#
For a visitor in a language other than the default:
- The plugin’s own translation for that language (Content & Text / Translations).
- WPML String Translation (
wpml_translate_single_string, the strings listed above). - The original text. If it is still the plugin’s English default, the built-in translation is shown.
Which way to choose#
- Plugin language panels: everything on one page, side by side with the original, with Fill in built-in translations. Includes the Portal UI Strings. Copied with Export / Import.
- WPML String Translation: fits a team that already translates everything in WPML, or uses WPML’s translation services. Translations live in WPML, so they are not in the plugin’s export file.
You can mix them: for example, fill the menu labels with the built-in translations and send the welcome message through WPML.
Polylang#
Polylang is supported for the language itself: the current language and default language, the plugin’s translation file per language, RTL detection, the language buttons in the settings and the /{language}/logout/ sign-out link. The plugin does not register strings with Polylang, so with Polylang translate your texts on Content & Text, Translations and Pages.
Related#
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!