Skip to main content

Widget Language

The Widget Builder picks the language in three separate places: for its own texts, for translations in custom widgets and built-in widgets, and for native bundles. Each place checks the details from Staffbase in its own order. That is why the Widget Builder's sign-in card can be German while a widget next to it shows English.

The details Staffbase supplies​

DetailWhere it comes fromExample
Profile languageLanguage in the Staffbase profile of the signed-in personde_DE
Content languageLanguage of the content the widget is placed in (contentLanguage from the Staffbase widget SDK). According to Staffbase it is not necessarily the language of the interfaceen_US
Company languageDefault language of your Staffbase environment. If Staffbase does not supply it, it stays emptyde_DE
Device languageLanguage setting of the browser or phonede-DE

Only the first two letters count for the choice: de_DE, de-AT and de all count as de.

Widget Builder texts​

These are the texts the Widget Builder shows itself, such as the "Sign in required" card or error messages. They exist in German and English. The first detail that matches wins:

  1. Profile language
  2. Device language
  3. Company language
  4. English

On pages whose address starts with /admin, only the device language counts, otherwise English.

Custom widgets and built-in widgets​

The {{t}} helper picks the column from the widget's translations. The Widget Builder determines the language for it like this:

  1. Profile language
  2. Profile language from the user object (user.locale)
  3. Content language
  4. Device language: the first language in the browser's or phone's list that the widget has a column for. If the widget has no translations, the first device language counts
  5. Company language
  6. English

So if neither profile nor content language is available, the widget is German on a German phone, even when Staffbase supplies no company language.

For the chosen language, {{t}} looks for the text in this order:

  1. the column of the language
  2. the en column
  3. the first column
  4. the key itself

The columns need two-letter language codes such as de, en or fr. A pt-BR column is never chosen, because the language is shortened to pt.

Native bundles​

A native bundle receives the details one by one and decides itself which language to show:

ValueContentExample
localeThe finished language, following the order for custom widgets (above). The built-in widget's translations count as columnsde
user.localeProfile language. Missing when Staffbase does not report a signed-in personde_DE
widget.contentLanguageContent language, unchangeden_US
defaultLocaleCompany language, empty if Staffbase supplies nonede_DE
browserLanguageFirst device language, two letters, en if there is nonede
settingsThe widget's settings in Staffbase Studio, for example a custom field for the language{ "language": "de" }

In the settings dialog of Staffbase Studio, the bundle also receives locale when it loads selection lists. This is the language of the dialog (de or en), not the language of the readers.

For your own native bundle, we recommend this order:

  1. a setting of its own in the widget, if your editors should decide the language
  2. user.locale
  3. widget.contentLanguage
  4. browserLanguage and the device languages
  5. defaultLocale

defaultLocale comes last and can be empty. Afterwards, check that your app offers the language to the customer at all, otherwise use English.

Example: room booking​

The JASP room booking (opens in new tab) is a native bundle. Its card picks the language like this:

  1. The Language field in the widget's settings in Staffbase Studio
  2. Profile language, first user.locale, then the profile language from the Staffbase session
  3. Content language
  4. Device language
  5. Company language
  6. English

The card then loads your tenant's settings in room booking. If the chosen language is not enabled there, it takes the first enabled language from the list above, otherwise the tenant's default language. A tenant with German only therefore always sees the card in German, even if Staffbase reports en_US or the Language field is set to en.

The card sends the chosen language with every request to room booking. The room names, the descriptions and the emails the person receives follow it.

An example: the content language is en_US, Staffbase reports no profile language, the phone is set to German, and the tenant has enabled German only. The list above first yields English, and the tenant turns it into German.