Skip to main content

Better Messages for Weglot: Multilingual Chat Interface

Compatibility
This guide compatible with Better Messages 2.15.18 or higher

Overview#

Weglot translates WordPress sites by rewriting the server-generated HTML and serving each language under its own URL prefix (for example /en/ or /de/). It does not change the WordPress site language, and it cannot reach texts rendered by JavaScript after the page has loaded.

The Better Messages interface is rendered by JavaScript, and all its labels come from Better Messages translation files which follow the WordPress site language. Without integration this means the messenger interface stays in the site default language on every Weglot language version.

Better Messages automatically detects Weglot and switches the messenger interface language to match the current Weglot language — the full messenger page, mini chat widgets, chat popups and dialogs all follow the language of the page the visitor is on.

info

The integration is included in both the free and WebSocket versions of Better Messages and activates automatically when Weglot is detected — no configuration needed

How it works#

  • On translated pages Better Messages loads its own translation for the current Weglot language, using standard WordPress translation files
  • On original language pages nothing changes
  • Conversation messages are never sent to Weglot — message content stays private and does not consume your Weglot translated words quota

Installing languages#

For every Weglot destination language, the matching WordPress language pack needs to be installed once:

  1. Go to Settings → General → Site Language, select the language and press Save Changes — this installs the language into WordPress
  2. Switch Site Language back to your original language and save again
  3. Repeat for each Weglot language
  4. Go to Dashboard → Updates and press Update Translations — Better Messages translations for the installed languages will download automatically

English requires no installation — the built-in Better Messages texts are English.

info

If a language pack is not installed, the messenger interface stays in the site default language on that Weglot language version

What is translated#

  • Interface texts — buttons, labels, placeholders, dialogs. These come from Better Messages translations and can be customized per language with Loco Translate, including English via an "English (United States)" translation
  • Conversation messages are not translated by this integration. To translate actual messages between users speaking different languages, use AI Message Translation
  • Custom texts entered in Better Messages settings are not part of translation files and stay exactly as entered

Customization#

Weglot uses two-letter language codes while WordPress uses full locales. Better Messages resolves them automatically — exact match or first installed regional variant (for example dede_DE), with special cases built in: enen_US, brpt_BR, zhzh_CN, twzh_TW, nonb_NO.

REQUIREMENTS

To be able to implement this guide, you need to learn how to insert PHP snippets to your website.

You can find guide here: WP Beginner

To override the mapping for a specific Weglot language code:

add_filter( 'better_messages_weglot_locales_map', function ( $map ) {
$map['en'] = 'en_GB';

return $map;
} );

For custom multilingual setups without Weglot, the underlying better_messages_i18n_locale filter controls which language the messenger interface loads on the current page:

add_filter( 'better_messages_i18n_locale', function ( $locale, $script_handle ) {
if ( my_site_is_english_version() ) {
return 'en_US';
}

return $locale;
}, 10, 2 );