App-level Language Setting (Flutter)
Last updated
Last updated
Please refer to the Language support table to learn the languages we supported.
Generally, the changeAppLanguage
API should be called in the following cases:
The App is launched(e.g. in the initState method of your App State.).
Users change the app language manually.
Other cases that change app language.
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.
On Android, we have two behaviors for switching languages: RestartingActivity
and NotRestartingActivity
. Different behaviors have different setup steps. You could choose one of them.
RestartingActivity
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:
To be able to use the in-app language feature, the following configuration needs to be added to the app project.
attachBaseContext
method in your MainActivity
.attachBaseContext
method in your MainApplication
.AndroidManifest.xml
NotRestartingActivity
To be able to use the in-app language feature, the following configuration needs to be added to the app project.
FWFlutterFragmentActivity
class in your MainActivity
.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.
Any theme starting with Theme.AppCompat
Any theme that extends the theme starting with Theme.AppCompat
Override the attachBaseContext
method in your MainApplication
.
Set NotRestartingActivity
behavior for language-switching in your MainApplication
Add androidx.appcompat:appcompat
library in app/firework.gradle
AndroidManifest.xml
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 |