Skip to main content

I18n

Carries language settings and loads language modules for the selected locale.

TODO: Write the documentation.

Accept-Language in AJAX Calls

Smart UI has always set the chosen UI language to the Accept-Language header, when making AJAX calls via Connector. It ensures a consistent language of static assets (language pack) and the data (REST API responses). The UI language is chosen by the locale setting:

require(['i18n'], function (i18n) {
console.log('locale:', i18n.settings.locale);
});

If you want to use a different locale for the data, you can set the property acceptLanguage, which will be sent to the server instead of locale:

require.config({
config: {
i18n: {
locale: 'en-US',
acceptLanguage: 'en-AU'
}
}
});

The values of both locale and acceptLanguage have to comply with BCP 47. They are case-insensitive and Smart UI will normalize them to lower-case before using them for loading static assets or sending in the Accept-Language header.

CS uses the property i18n.settings.userMetadataLanguage to support multi-lingual UI. Unfortunately, this property does not follow BCP 47. If userMetadataLanguage is set and acceptLanguage is unset, Smart UI will convert the value of userMetadataLanguage to acceptLanguage. If both acceptLanguage and userMetadataLanguage are unset, Smart UI will set the value of locale to acceptLanguage to stay compatible with previous versions.

Setting acceptLanguage to null will stop Smart UI from setting the Accept-Language header in AJAX calls:

require.config({
config: {
i18n: {
locale: 'en',
acceptLanguage: null
}
}
});