In this section

Resources / Developers / Embed

Set visitor language

Use window.hubbo.setLang so the embed picks the right translation overlays for notifications, NPS, surveys and the roadmap board.

When your product has its own language switcher (or you know the user’s locale from their account), call window.hubbo.setLang() after the embed script loads. Hubbo stores the preference in the browser and uses it first when applying AI Translation overlays.

Priority order

When `setLang` is set, Hubbo uses that locale only (missing overlay → main language — it does not fall through to the browser). When unset: browser navigator.language, then optional identify traits locale / language. Empty fields still fall back to the main language.

API

// After the embed script has loaded
window.hubbo?.setLang('pl');      // or 'pl-PL' — Hubbo keeps the primary subtag
window.hubbo?.setLang('es-MX');

// Read the stored preference (normalized), or null
const lang = window.hubbo?.getLang(); // 'pl' | 'es' | null

// Clear — fall back to browser language (and identify traits)
window.hubbo?.setLang(null);
  • setLang accepts a BCP-47 tag; Hubbo normalizes to the primary language subtag (pl-PL → pl).
  • Empty, null, or invalid values clear the preference.
  • The preference is stored in the host page’s local storage under the Hubbo key and survives reloads until cleared.
  • reset() (logout) does not clear the language — call setLang(null) when you want the browser language again.
  • Widgets re-apply translation overlays when setLang fires (same tick pattern as identify).
  • The notification widget passes lang on the /page iframe and post URLs so the feed and opened posts match setLang even before bootstrap.
  • Shared notification page chrome (back, share, chat labels) is edited under Notifications → Translations and follows the same locale rules.

Where it applies

setLang drives the embed on your site (notifications including the widget bell feed, NPS, surveys, and the inline roadmap Web Component). On public status and roadmap pages (app.hubbo.io), the same window.hubbo.setLang / getLang API is available and re-localizes live — it also syncs ?lang= in the URL. Shared links with ?lang= still work without calling the API. Roadmap iframes from the embed pass lang from host setLang.

Related: Translations and languages, Identify visitors, Embed script reference.