Developers

Translating Super Speedy Chat (i18n)

Published · Last updated

Super Speedy Chat is built for translation. Every string the plugin renders itself, in wp-admin and in the PHP that assembles the front-end, is wrapped in the standard WordPress translation functions, so you can localise the whole admin experience with the tools you already use. A few strings work differently, either because you type them yourself in the settings or because they live inside the front-end JavaScript. This guide is precise about which strings are translatable which way, so you know exactly where to spend your effort.

The text domain

The plugin’s text domain is super-speedy-chat. It is declared in the plugin header of super-speedy-chat.php:

Text Domain: super-speedy-chat

Every translation call across the codebase uses that same domain, for example __( 'Welcome Message', 'super-speedy-chat' ). When you build a .po/.mo pair, the filename must include this text domain and the locale, for example super-speedy-chat-fr_FR.mo.

How translations load

Super Speedy Chat does not ship a /languages directory and does not call load_plugin_textdomain(). It relies on WordPress’s just-in-time (JIT) translation loading instead. Since WordPress 4.6, the first time a string in the super-speedy-chat domain is translated, WordPress automatically looks for a matching .mo file in the global plugin-translations folder, wp-content/languages/plugins/super-speedy-chat-{locale}.mo, and loads it. No registration call is needed.

Because JIT loading only works after WordPress is far enough into the request, the plugin is careful never to translate a string at file-load time. Hook wiring that would trigger __() is deferred to plugins_loaded, which avoids the “\_load_textdomain_just_in_time called too early” notice on WordPress 6.7 and later. You do not need to do anything about this, but it is worth knowing that the correct place for your .mo files is the global wp-content/languages/plugins/ folder, not a folder inside the plugin.

Translating the admin and PHP strings

These are the bulk of the plugin’s strings: settings-page labels and descriptions, the Chats inbox, notices, email-fallback text, and the Discord and WhatsApp admin panels. All of them go through __(), _e(), esc_html__(), esc_html_e(), esc_attr_e() and _x() with the super-speedy-chat domain, so any standard workflow picks them up.

You have two practical routes.

Loco Translate (recommended for most people). Install Loco Translate, open Super Speedy Chat under its plugin list, and create a new language. Loco scans the source, presents every translatable string, and writes the .po/.mo pair. Save the translation to the “System” (WordPress languages) location so it lands in wp-content/languages/plugins/ and survives plugin updates. Translate in the browser and you are done.

Hand-authored .po/.mo. If you prefer Poedit or a translation pipeline, generate a POT by scanning the plugin source, translate it, and place the compiled super-speedy-chat-{locale}.mo in wp-content/languages/plugins/. WordPress will pick it up via JIT loading.

Either way, which translation is used depends on the site language set in Settings, General (or the per-user language in your profile). Set the site to the target locale and the admin strings appear translated.

Strings you translate in the settings, not in a .po file

Some of the most visible text is not a fixed string in the code at all. It is content you author in the settings, so you simply type it in your own language and it is stored as-is. Do not try to translate these through a .po file, because the value a .po would override is only the English default.

The main ones are:

  • Welcome Message (ssc_welcome_message, on the Automated Responses tab), shown when a visitor opens the widget. Its English default is “Hi! How can we help you today?” but whatever you save is used verbatim.
  • Chat Window Title, set in the Customizer (Appearance, Super Speedy Chat), stored as ssc_customizer[window_title], default “Chat”.
  • Canned responses and the LLM system prompt are free text you write. Author them in your target language. See Canned Responses and LLM Auto-Reply Setup Guide.

On a single-language site this is the simplest path for the greeting and title: just write them in the language your visitors speak.

The front-end chat widget strings

The visitor-facing bubble is rendered by assets/chat-bubble.js. It reads a configuration blob (ssc_config) that PHP builds in ssc_enqueue_frontend_assets() and passes with wp_localize_script(). Only two keys in that blob are display text: welcome_message and window_title. Everything else is URLs, numbers, colours and booleans.

Overriding the welcome message with the ssc_frontend_config filter

Just before the config is localised, the plugin runs it through the ssc_frontend_config filter. This is the supported PHP hook for changing what the widget shows, and it is the same hook the channel add-ons use to append their own keys. The following example changes the front-end welcome label per locale, grounded in the real welcome_message key:

add_filter( 'ssc_frontend_config', function( $config ) {
    $locale = determine_locale();

    $greetings = array(
        'fr_FR' => 'Bonjour ! Comment pouvons-nous vous aider ?',
        'de_DE' => 'Hallo! Wie koennen wir helfen?',
    );

    if ( isset( $greetings[ $locale ] ) ) {
        $config['welcome_message'] = $greetings[ $locale ];
    }

    // The window/header title is also a plain config key.
    if ( 'fr_FR' === $locale ) {
        $config['window_title'] = 'Discussion';
    }

    return $config;
}, 20 );

Because this runs server-side, the correct greeting is baked into the page for each visitor’s locale. See Developer Guide: Hooks and Building Channel Add-ons for the full filter surface and Customizing the Chat Widget Appearance for the appearance settings behind these keys.

The window.ssc.hooks JavaScript filter

The bubble also exposes a small hooks library at window.ssc.hooks, mirroring the WordPress @wordpress/hooks API (addFilter, applyFilters, addAction, doAction). One text filter is available for translation purposes, ssc.bubble.welcomeMessage, applied to the welcome message just before it is shown:

<script>
window.ssc = window.ssc || {};
window.ssc.hooks && window.ssc.hooks.addFilter(
    'ssc.bubble.welcomeMessage',
    'my-theme/i18n',
    function ( message ) {
        return 'Bonjour ! Comment pouvons-nous vous aider ?';
    }
);
</script>

Enqueue this so it runs before the bubble renders. For most sites the PHP filter above is cleaner, but the JS hook is useful when your locale is only known client-side.

Strings currently hardcoded in the bubble JS

Be aware that several small pieces of widget chrome are English literals inside chat-bubble.js and are not exposed through the config, the ssc_frontend_config filter, or a text domain. These include “Open chat” and “Close chat” (aria labels), the “Type a message…” placeholder, the “Send” buttons, the email-prompt line “Leave your email and we’ll notify you when we reply:” with its “your@email.com” placeholder, the “Log in” / “create an account” invitations, and the “Powered by Super Speedy Chat” credit. There is no filter for these today, so translating them means editing the JavaScript directly (keep a copy, as a plugin update will overwrite it). If you need these localised as standard, it is worth raising, since the welcome message and window title already flow cleanly through settings and the config filter.

Bubble chrome is not in the text domain

A .po/.mo translation will not touch the small English literals baked into chat-bubble.js (“Send”, “Type a message…”, the aria labels, the email prompt). Only the welcome message and window title flow through settings and the ssc_frontend_config filter. Everything else in the bubble needs a direct JS edit today, which a plugin update overwrites.

Summary

String groupTranslate via
Admin and PHP stringsLoco Translate or .po/.mo in wp-content/languages/plugins/, driven by the site language
Welcome message, window titleThe settings themselves, or the ssc_frontend_config filter (welcome_message, window_title)
Welcome message (client-side)The ssc.bubble.welcomeMessage filter on window.ssc.hooks
Canned responses, LLM promptWritten directly in the settings in your language
Bubble chrome (“Send”, “Type a message…”, etc)Editing chat-bubble.js (no filter yet)

For the endpoints these front-end strings talk to, see REST API Reference.

Further reading

the full `ssc_frontend_config` filter surface and JS hooks
where the window title is set
the endpoints behind the front-end strings

Comments

▲
▼
1/1