Localization

Introduction

If your app supports multiple languages, the chat SDK has support for localizations. For example, you can add more languages, or you can change translations for the existing texts used throughout the SDK.

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. StreamChatSwiftUI's framework bundle.
  3. 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 right after initializing StreamChat.

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 StreamChatSwiftUI can be overridden through the localizationProvider. The full set of keys (and their default English translations) lives in: