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
| Detail | Where it comes from | Example |
|---|---|---|
| Profile language | Language in the Staffbase profile of the signed-in person | de_DE |
| Content language | Language 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 interface | en_US |
| Company language | Default language of your Staffbase environment. If Staffbase does not supply it, it stays empty | de_DE |
| Device language | Language setting of the browser or phone | de-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:
- Profile language
- Device language
- Company language
- 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:
- Profile language
- Profile language from the user object (
user.locale) - Content language
- 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
- Company language
- 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:
- the column of the language
- the
encolumn - the first column
- 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:
| Value | Content | Example |
|---|---|---|
locale | The finished language, following the order for custom widgets (above). The built-in widget's translations count as columns | de |
user.locale | Profile language. Missing when Staffbase does not report a signed-in person | de_DE |
widget.contentLanguage | Content language, unchanged | en_US |
defaultLocale | Company language, empty if Staffbase supplies none | de_DE |
browserLanguage | First device language, two letters, en if there is none | de |
settings | The 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:
- a setting of its own in the widget, if your editors should decide the language
user.localewidget.contentLanguagebrowserLanguageand the device languagesdefaultLocale
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:
- The Language field in the widget's settings in Staffbase Studio
- Profile language, first
user.locale, then the profile language from the Staffbase session - Content language
- Device language
- Company language
- 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.