App-level Language Setting (React Native)

Use API on JS/TS side

Call API on JS/TS side

import FireworkSDK from 'react-native-firework-sdk';

// You should pass language code to this API, such as "en", "ar" and "pt-BR".
FireworkSDK.getInstance().changeAppLanguage('ar');

Generally, the changeAppLanguage API should be called in the following cases:

  1. The App is launched(e.g. in the componentDidMount method of App component).

  2. Users change the app language manually.

  3. Other cases that change app language.

Calling sequence

Generally, you also have codes for switching languages, such as the codes of caching the language.

  1. Please call FireworkSDK.getInstance().changeAppLanguage before RNRestart.Restart

  2. Please call FireworkSDK.getInstance().changeAppLanguage after all your other codes for switching languages, such as the codes of caching the language.

For example:

Additional setup steps on iOS

Firework SDK widgets are based on native views. Hence, as shown in the screenshot below, you need to add the localizations you want to support to the iOS project, which is required by iOS framework.

Additional setup steps on Android

To be able to use the in-app language feature, the following configuration needs to be added to the app project.

Override the attachBaseContext method in MainActivity.

If you need to support RTL, then please add the following configuration to the AndroidManifest.xml

Use API on native sides

Generally, you should use changeAppLanguage API on JS/TS side. But we also support using this API on native sides directly.

Change app language on iOS native side

Generally, the changeAppLanguage API should be called in the following cases:

  1. The App is launched(e.g. in the application(:, didFinishLaunchingWithOptions:) -> Bool method).

  2. Users change the app language manually.

  3. Other cases that change app language.

After calling changeAppLanguage API, we need to recreate FireworkVideo SDK components to update the UI. Such as:

  • Recreate video feed and story block

  • Stop floating player

Additional setup steps on iOS

Firework SDK widgets are based on native views. Hence, as shown in the screenshot below, you need to add the localizations you want to support to the iOS project, which is required by iOS framework.

Change app language on Android native side

Step 1: The following methods need to be prepared

Step 2: Add the following code to all activities

Step 3: Call the change language method where you need

Language support table

Language
Language code
iOS
iOS translation
Android
Android translation

English

en

Supported

100%

Supported

100%

Spanish

es

Supported

76%

Supported

41.1%

Portuguese(Brazil)

pt-BR

Supported

58%

Supported

41.1%

Russian

ru

Supported

52%

Supported

26.3%

Polish

pl

Supported

64%

Supported

41.1%

Japanese

ja

Supported

76%

Supported

43.2%

Arabic

ar

Supported

80%

Supported

85.3%

Persian

fa

Not supported

NA

Supported

86.3%

Last updated

Was this helpful?