Localization

If you deploy your app to users who speak another language, you'll need to internationalize (localize) it. That means you need to write the app in a way that makes it possible to localize values like text and layouts for each language or locale that the app supports.

Appearance.default.localizationProvider resolves every user-facing string. By default, it walks a fallback chain on each lookup:

  1. Your app's Bundle.main.
  2. The shared StreamChatCommonUI bundle (the SDK's bundled defaults).

You can customize any SDK string by adding it to your own Localizable.strings / Localizable.stringsdict. The SDK picks up your overrides automatically; you don't need to install a custom localization provider for the common case.

Customizing localizations

  1. If you don't have Localizable.strings / Localizable.stringsdict files in your project, add them.
  2. Add the keys you want to override. If you're translating to a new locale, also register the language in your project.
  3. Run the app. Your strings replace the SDK's defaults for the keys you provided; the rest keep using the SDK's bundled translations.

For example, to rename the "and" / "and N more" separators in channel names, add the following to your app's Localizable.strings:

"channel.name.and" = "&";
"channel.name.andXMore" = "& %@ more";

Every other key continues to use the SDK's default translation, so new keys introduced in future SDK releases keep working without any changes on your side.

We recommend naming your strings and stringsdict files: Localizable.strings and Localizable.stringsdict.

Advanced: replacing the localization provider

For setups where you can't or don't want to put translations in Bundle.main (for example, sourcing them from a server, a feature flag, or a separate bundle), you can replace the provider entirely. Always capture the default localizationProvider and forward unmatched keys to it, so the SDK's bundled translations keep working as a fallback:

let localizationProvider = Appearance.default.localizationProvider
Appearance.default.localizationProvider = { key, table in
    if let customString = MyTranslator.translation(forKey: key, table: table) {
        return customString
    }
    return localizationProvider(key, table)
}

Set the localizationProvider as early as possible in the app lifecycle, for example in the AppDelegate.

If you replace the provider, always chain through to the default for unmatched keys. A closure that only reads from your own source will make every key the SDK introduces in a future release render as the raw key (for example, channel.name.missing).

Resources

Every string used by StreamChatUI is shipped from the shared StreamChatCommonUI module and can be overridden through the localizationProvider. The full set of keys (and their default English translations) lives in:

Automatic Translation

Stream Chat provides the ability to run users' messages through automatic translation. While machine translation is never perfect it can enable two users to communicate with each other without speaking the same language.

In order to enable automatic translation, the following steps are required to do in the Client SDKs:

Enabling the feature in the UIKit SDK through

Components.default.messageAutoTranslationEnabled = true

Providing the language when connecting the user

connectUser(userInfo: UserInfo(id:"userId", language: .english))

For more information, see the full guide to adding automatic translation.