Firework for Developers
One-to-one Virtual ShoppingBusiness Portal
  • Welcome to Firework for Developers
  • Firework Interactive Video and One-to-many Digital Showroom
  • Web
    • Getting Started (Web)
      • Shopify
      • Magento
      • Wordpress (WooCommerce)
      • Salesforce Commerce Cloud
      • BigCommerce
    • Integration Guide for Web
      • Components
        • Hero Unit
        • Carousel / Grid
        • Storyblock (Web)
        • Player (Floating)
        • Storylink
      • Styling
      • Feed Attributes
      • Player
        • Configuration
          • Appearance
      • Video customization
        • Video Factory
        • CTA Button
        • Product cards
      • Events
        • Embed Feed and Storyblock Events
        • Video player events
        • Live stream events
        • Shopping events
      • Shopping Integration (V2)
        • Introduction
        • Shopping APIs
        • Product Hydration
        • Product Factory
        • Cart Sync
        • Tracking
          • Purchase
          • Add to cart
          • Remove from cart
          • Page viewed
        • Shopping Integration FAQ
        • Migrate from V1
      • Web SDK
      • Enhanced Picture-in-Picture
      • Privacy settings
        • Tracking settings
        • Cookies management
        • Content Security Policy
    • Telemetry console
    • Firework Service Domains
    • FAQ & Troubleshooting (Web)
  • Android SDK
    • Integration Guide for Android SDK
      • Getting Started (Android)
      • Video Feed (Android)
        • Video Feed Layouts (Android)
        • Channel Feed (Android)
        • Discover Feed (Android)
        • Playlist Feed (Android)
        • Dynamic Content Feed
        • Channel Hashtags Feed
        • Sku Feed
        • Single Content Feed
        • Configure Video Feed
      • Customization
        • CTA
      • Analytics (Android)
      • Shoppable Videos (Android)
        • Product Hydration
      • Live Stream Support (Android)
      • Video Player (Android)
      • StoryBlock (Android)
      • Share & Video Deep linking
      • Ad Support (Android)
      • Configure Video Advertisements Source (Android)
      • In-app Language Switches
      • Compose support(Android)
    • Sample App (Android)
    • FAQ & Troubleshooting (Android)
    • Changelog (Android)
  • iOS SDK
    • Integration Guide for iOS SDK
      • Getting Started (iOS)
      • ATT compliance (iOS)
      • Video Feed (iOS)
        • Discover Feed(iOS)
        • Channel Feed (iOS)
        • Playlist Feed (iOS)
        • Playlist Group Feed (iOS)
        • Dynamic Content (iOS)
        • Hashtag Playlist (iOS)
        • SKU Playlist (iOS)
        • Video Ads (iOS)
        • Video Feed Layouts (iOS)
      • Story Block (iOS)
      • Customization (iOS)
        • Video feed configurations (iOS)
        • Player configurations (iOS)
        • Shopping configurations (iOS)
          • Customize product card on videos using the custom view (iOS)
        • Customize click behaviors (iOS)
      • Shopping (iOS)
      • Live Stream Support (iOS)
      • Analytics (iOS)
      • Share & Deeplinking(iOS)
      • Ad Support (iOS)
    • Sample App (iOS)
    • FAQ & Troubleshooting (iOS)
    • Changelog (iOS)
  • React Native SDK
    • Integration Guide for React Native SDK V2
      • Getting Started (React Native)
      • ATT compliance React Native (iOS)
      • Video Feed (React Native)
      • Story Block (React Native)
      • Customization (React Native)
        • Video feed configurations (React Native)
        • Player configurations (React Native)
        • Shopping configurations (React Native)
          • Customize product card on videos using the custom view (React Native)
        • Customize click behaviors (React Native)
      • Shopping (React Native)
      • Live Stream Support (React Native)
      • Ad Support (React Native)
      • Analytics (React Native)
      • App-level Language Setting (React Native)
      • Share & Video Deeplinking (React Native)
      • Android Style (React Native)
      • Inject Android Image Loader (React Native)
      • Integrate SDKs in Hybrid React Native and native Apps
      • Reference (React Native)
      • Sample App (React Native)
      • FAQ & Troubleshooting (React Native)
      • Changelog (React Native)
  • Flutter SDK
    • Integration Guide for Flutter SDK V2
      • Getting Started (Flutter)
      • ATT compliance Flutter (iOS)
      • Video Feed (Flutter)
      • Story Block (Flutter)
      • Customization (Flutter)
        • Video feed configurations (Flutter)
        • Player configurations (Flutter)
        • Shopping configurations (Flutter)
          • Customize product card on videos using the custom view (Flutter)
        • Customize click behaviors (Flutter)
      • Live Stream Support (Flutter)
      • Shopping (Flutter)
      • Ad Support (Flutter)
      • Analytics (Flutter)
      • App-level Language Setting (Flutter)
      • Share & Video Deeplinking (Flutter)
      • Inject Android Image Loader (Flutter)
      • Android Style (Flutter)
      • Integrate SDKs in Hybrid Flutter and native Apps
      • Reference (Flutter)
      • Sample App (Flutter)
      • FAQ & Troubleshooting (Flutter)
      • Changelog (Flutter)
  • Help Articles
    • Importing Products to Firework
    • Adding products to a video
    • Displaying product videos on product pages using hashtag filtering(Web)
    • Syncing Carts
    • Encoded IDs
Powered by GitBook
On this page
  • Dart integration
  • Additional setup steps on iOS
  • Additional setup steps on Android
  • Option 1: Setup steps for RestartingActivity
  • Option 2: Setup steps for NotRestartingActivity
  • Language support table

Was this helpful?

  1. Flutter SDK
  2. Integration Guide for Flutter SDK V2

App-level Language Setting (Flutter)

PreviousAnalytics (Flutter)NextShare & Video Deeplinking (Flutter)

Last updated 3 days ago

Was this helpful?

Dart integration

import 'package:fw_flutter_sdk/fw_flutter_sdk.dart';

// You should pass language code to this API, such as "en", "ar", "pt-BR" and "hu" etc.
// For the language codes we support, please refer to "Language support table" below.
FireworkSDK.getInstance().changeAppLanguage("ar");

Please refer to the to learn the languages we supported.

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.

Additional setup steps on iOS

Firework SDK widgets are based on native views. Thus, as depicted in the screenshot below, you must add all the language localizations you wish to support to the iOS project, as required by Apple.

Additional setup steps on Android

We also require some additional setup steps on Android. On Android, there are two behaviors for switching languages: RestartingActivity and NotRestartingActivity. Each behavior involves different setup steps, and you can choose either one.

Option 1: Setup steps for RestartingActivity

RestartingActivity option will restart the Android activity when changing the app language.

Calling sequence

Currently, FireworkSDK.getInstance().changeAppLanguage will recreate the activity by default 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 your MainActivity.

import com.fireworksdk.bridge.flutter.FWFlutterSDK

class MainActivity: FlutterFragmentActivity() {
  
  override fun attachBaseContext(newBase: Context) {
    super.attachBaseContext(FWFlutterSDK.updateBaseContextLocale(newBase))
  }
}

Optional: Override the attachBaseContext method in your MainApplication.

class MainApplication: FlutterApplication() {
  
  override fun attachBaseContext(base: Context) {
    // If you can know the app language here, you could also call FWFlutterSDK.changeLanguage here to sync the app language to SDK. Such as:
    // FWFlutterSDK.changeLanguage("en", base)
    super.attachBaseContext(FWFlutterSDK.updateBaseContextLocale(base))
  }
}

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

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

Option 2: Setup steps for NotRestartingActivity

NotRestartingActivity option won't restart the Android activity when changing the app 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.

Inherit the FWFlutterFragmentActivity class in your MainActivity.

import com.fireworksdk.bridge.flutter.base.FWFlutterFragmentActivity

class MainActivity: FWFlutterFragmentActivity()

Configure the theme in your MainActivity

add android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" to the file app/src/Androidmanifest.xml

Besides the Theme.AppCompat.DayNight.NoActionBar, you could also use a theme that meets one of the following conditions.

  1. Any theme starting with Theme.AppCompat

  2. Any theme that extends the theme starting with Theme.AppCompat

    <application
        android:name=".MainApplication"
        ...>
        <activity
            android:name=".MainActivity"
            ...
            android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
        </activity>
    </application>

Override the attachBaseContext method in your MainApplication.

class MainApplication: FlutterApplication() {
  
  override fun attachBaseContext(base: Context) {
    super.attachBaseContext(FWFlutterSDK.updateBaseContextLocale(base))
  }
}

Set NotRestartingActivity behavior for language-switching in your MainApplication

class MainApplication: FlutterApplication() {
  
  override fun onCreate() {
    super.onCreate()
    // We suggest setting behavior before you invoke FWFlutterSDK.init()
    FWFlutterSDK.setLanguageSwitchingBehavior(FWSwitchLanguageBehavior.NotRestartingActivity)
    // Invoke FWFlutterSDK.init() for initialize FWFlutterSDK
    ...
  }
}

Add androidx.appcompat:appcompat library in app/firework.gradle

dependencies {
  implementation 'androidx.appcompat:appcompat:1.6.1'
  ...
}
...

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

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

Language support table

Language
Language code

English

en

Arabic

ar

Arabic (Saudi Arabia)

ar-SA

Arabic (United Arab Emirates)

ar-AE

German

de

Italian

it

Japanese

ja

Polish

pl

Portuguese (Brazil)

pt-BR

Russian

ru

Spanish

es

Spanish (Mexico)

es-MX

Spanish (Colombia)

es-CO

Vietnamese

vi

Thailand

th

Hungarian

hu

Turkish

tr

French

fr

Portuguese

pt

Language support table