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:
- The language you set with
overrideDefaultLocale, if any. - The language of the device, or the per-app language the user chose in the system settings.
- 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:
| Language | Code |
|---|---|
| Arabic | ar |
| Chinese (Simplified) | zh-CN |
| Chinese (Traditional) | zh-TW |
| Danish | da |
| Dutch | nl |
| English (fallback) | en |
| Finnish | fi |
| French | fr |
| German | de |
| Hindi | hi |
| Indonesian | id |
| Italian | it |
| Japanese | ja |
| Malay | ms |
| Norwegian (Bokmål) | nb |
| Polish | pl |
| Portuguese | pt |
| Romanian | ro |
| Russian | ru |
| Spanish | es |
| Swedish | sv |
| Thai | th |
| Turkish | tr |
| Vietnamese | vi |
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.
- Android
- iOS
- Flutter
- React Native
- Unity
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)
}
The SDK does not check the Locale you pass. An unknown language falls back to English.
Since 1.15.0, translations have been refreshed across all locales, including the wording of report reasons, "Terms of Use" and "Powered by". Review your app's string overrides against the SDK resources. Move any override of accessibility_common_close to common_close. The former congratulations strings validate_nickname_action_later, validate_nickname_action_modify, validate_nickname_modification, validate_nickname_nickname and validate_nickname_title are unused: delete overrides of them.
overrideDefaultLocale(with: Locale?) takes a BCP-47 locale: a language and an optional region, separated by -. Pass nil to go back to the system language.
// A language only
octopus.overrideDefaultLocale(with: Locale(identifier: "fr"))
// A language and a region: Portuguese is used, Brazilian Portuguese has no translation of its own
octopus.overrideDefaultLocale(with: Locale(identifier: "pt-BR"))
// Back to the system language
octopus.overrideDefaultLocale(with: nil)
≥ 1.15.0 Translations have been refreshed in every supported language. In English, consent checkboxes now say Terms of Use instead of Terms and Conditions. Update any copy in your app that quotes the SDK wording.
See the language manager of the iOS sample.
The SDK does not check the Locale you pass. An unknown language falls back to English.
Pass null to go back to the system language.
// A language only
await octopus.overrideDefaultLocale(const Locale('fr'));
// A language and a region
await octopus.overrideDefaultLocale(const Locale('en', 'US'));
// Back to the system language
await octopus.overrideDefaultLocale(null);
The SDK does not check the Locale you pass. An unknown language falls back to English.
Pass null to go back to the system language.
import { overrideDefaultLocale } from '@octopus-community/react-native';
// A language only
await overrideDefaultLocale({ languageCode: 'fr' });
// A language and a region
await overrideDefaultLocale({ languageCode: 'en', countryCode: 'US' });
// Back to the system language
await overrideDefaultLocale(null);
overrideDefaultLocale throws an Error when languageCode is not two letters, or when countryCode is present and not two letters. A well-formed but unsupported language falls back to English.
OverrideDefaultLocale(string languageCode) takes a language code.
OctopusSDK.OverrideDefaultLocale("fr");
Pass a language only: on Android, a region such as en-US is not understood and falls back to English. Unity has no call to go back to the system language.
Behavior and limits
- The override applies to the SDK UI only. System screens keep the device language.