Skip to main content

Localization

The community UI follows the device language when it is supported. You can also force a language from your app.

Before you begin​

  • Initialize the SDK: see Initialize the SDK.
  • Prefer the system per-app language when you can. Your users then see system alerts and system screens, such as the photo picker, in the same language as the community.

How it works​

The SDK picks the language in this order:

  1. The language you set with overrideDefaultLocale, if any.
  2. The language of the device, or the per-app language the user chose in the system settings.
  3. English, when the language is not supported.

A language with a region, such as Brazilian Portuguese, uses the base language when the region has no translation of its own.

The SDK UI is available in these languages:

LanguageCode
Arabicar
Chinese (Simplified)zh-CN
Chinese (Traditional)zh-TW
Danishda
Dutchnl
English (fallback)en
Finnishfi
Frenchfr
Germande
Hindihi
Indonesianid
Italianit
Japaneseja
Malayms
Norwegian (Bokmål)nb
Polishpl
Portuguesept
Romanianro
Russianru
Spanishes
Swedishsv
Thaith
Turkishtr
Vietnamesevi

Override the language​

Call overrideDefaultLocale when your app has its own language setting that does not set the system per-app language. The language is a two-letter ISO 639-1 code. The region, when you pass one, is a two-letter ISO 3166-1 code.

overrideDefaultLocale(locale: Locale?) is a suspend function: call it from a coroutine. Pass null to go back to the system language.

import java.util.Locale

lifecycleScope.launch {
// A language only
OctopusSDK.overrideDefaultLocale(Locale.FRENCH)

// A language and a region: Portuguese is used, Brazilian Portuguese has no translation of its own
OctopusSDK.overrideDefaultLocale(Locale("pt", "BR"))

// Back to the system language
OctopusSDK.overrideDefaultLocale(null)
}
note

The SDK does not check the Locale you pass. An unknown language falls back to English.

Behavior and limits​

  • The override applies to the SDK UI only. System screens keep the device language.

Next steps​