App-level Language Setting

Integration

JS/TS

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

FireworkSDK.getInstance().changeAppLanguage('ar'); // format: ar or ar-JO

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.

If there is a react-native restart code in your app. Please add the code before the react-native restart code. Such as:

await FireworkSDK.getInstance().changeAppLanguage(language);
RNRestart.Restart();

Android

Please add the code to your MainActivity.java file.

import com.fireworksdk.bridge.utils.FWLanguageUtil;

public class MainActivity extends ReactActivity {

  ...

  @Override
  protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(FWLanguageUtil.INSTANCE.updateBaseContextLocale(newBase));
  }
}

iOS

No code configuration is required.

Change app language on iOS native side

import FireworkVideoUI
AppLanguageManager.shared.changeAppLanguage("ar") // such as ar, ar-JO, en, etc.

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

Last updated