App-level Language Setting

Integration

import 'package:fw_flutter_sdk/fw_flutter_sdk.dart';

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

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

  1. The App is launched(e.g. in the initState method of your App State.).

  2. Users change the app language manually.

  3. Other cases that change app language.

Calling sequence

Currently, FireworkSDK.getInstance().changeAppLanguage will recreate the activity on Android. Therefore, we need to follow the calling sequence.

Generally, you also have codes for switching languages, such as the codes of caching the language. Please call FireworkSDK.getInstance().changeAppLanguage after all your codes for switching languages. For example:

import 'package:localstorage/localstorage.dart';

const language = "ar";

// cache language
await localStorage.setItem("app_language", language);

// We need to call SDK changeAppLanguage API after your codes for switching languages,
// such as the codes of caching the language
await FireworkSDK.getInstance().changeAppLanguage(language);

Add codes on Android project

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.

import com.fireworksdk.bridge.flutter.FWFlutterSDK

class MainActivity: FlutterFragmentActivity() {

  // please add the code
  override fun attachBaseContext(newBase: Context) {
    super.attachBaseContext(FWFlutterSDK.updateBaseContextLocale(newBase))
  }
}

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

    <application
        ...
        android:supportsRtl="true"
    >
    ...

Language support table

LanguageLanguage codeiOSiOS translationAndroidAndroid 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