Skip to main content
Version: v5

Adding Localization

The Android SDK's UI Components are available in multiple languages out-of-the-box. At the moment we support the following languages (and more will be added in the future):


English is used as the default language.


If your app doesn't support all these languages, you might want to remove some of them.


What is Localization?

If you deploy your app to users who speak another language, you might want 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. For more information, see the official Android documentation.

Support for different languages in the SDK is based on the standard Android mechanism of switching resources on system locale change. The locale will be set automatically, based on system preferences. You can provide custom localization for the SDK's string resources by overriding them in the locale-specific /res/values directories of your project.

All of the string resources names provided by Stream SDK are prefixed with stream_ui_, for example:

<string name="stream_ui_message_list_empty">No messages</string>

These strings are also grouped in resource files prefixed with strings_. Each file corresponds to a related UI component or specific usage. You can browse them in order to provide translations:

Adding a new language

Let's see how you can add support for additional languages in the SDK. As an example, we'll implement a custom Polish language translation for the ChannelListHeaderView UI component.

Usually, base string resources are located in the /res/values/strings.xml file. In order to add translations for the new language (PL) we are going to create a new strings.xml file under res/values-pl directory.

Let's take a look at the strings_channel_list_header.xml file and discover strings defined for ChannelListHeaderView:

<?xml version="1.0" encoding="utf-8"?>
<string name="stream_ui_channel_list_header_connected">Stream Chat</string>
<string name="stream_ui_channel_list_header_disconnected">Waiting for network</string>

As you can see there are two string resources used by this UI component. Let's say we need to localize only the one called stream_ui_channel_list_header_disconnected.

In order to do that, we need to add the following string resource to the target locale-specific file. In our case, this will be the res/values-pl/strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<string name="stream_ui_channel_list_header_disconnected">Oczekiwanie na połączenie</string>

As the result, your app will display Oczekiwanie na połączenie text on devices set to a Polish locale.

Overriding existing languages

To override strings for a language supported by default, create new string resources in the locale-specific /res/values-XX directories of your project with the same name. Here you can find a list of available text resources grouped by component.

Overriding the default language

To change the strings used by default, place the string resources you want to override inside the /res/values directory directory.

Removing existing languages

The Android UI Components include resources for all of the languages mentioned above. If your app doesn't support all those languages, you can exclude some of them by explicitly defining a list of supported languages inside your build.gradle file:

defaultConfig {
resConfigs "en", "es"

With the configuration here, your app will include only English and Spanish resources.

Translating User Messages

Stream Chat provide 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. For more information, see the full guide to adding automatic translation.

Did you find this page helpful?