In-App Localization is something that is required if your app is going to be used in a country with different languages. Also, if you want to increase your user base, then it is quintessential that you incorporate user’s local language. This blog is related to In-App localization in Flutter. With the help of this, you are free to write an app incorporating local language. Flutter supports localization and to identify the user’s language it uses Locale class.
Below is the basic step-by-step tutorial that explains the implementation process.
To use localization in our project we need to use the flutter_localizations package. Add below dependencies to your pubspec.yaml file that allows your project for localization and translation.
Import dart file.
Add localization delegates and supported locales
Fetch locale by getting the language and country code from shared preferences.
Update locale at the time of language change and save it to a shared preference.
Create localization and respective Delegate class. Delegate class uses localization class on flutter app. An abstract LocalizationsDelegate class is available in flutter for declaring your delegate class.
Here AppLocalizations.of(context).appNameShort gets the value from current selected locale.
And that’s it!
By using the above steps you can create an app with local languages.
You can get the full source code of this demo from this Github repository. Don’t forget to give star and share the repo, this might help someone else!!
We’ve been working on Flutter from quite some time now. You can connect with us on our Facebook page for any flutter related queries.