flutter_translate
The internationalization (i18n) library for Flutter.
It lets you define translations for your content in different languages and switch between them easily.
Installation
Add this to your package's pubspec.yaml file:
Install packages from the command line (or from your editor):
Configuration
Import flutter_translate:
Place the json localization files in a folder of your choice within the project.
By default flutter_translate
will search for localization files in the assets/i18n
directory in your project's root.
Declare your assets localization directory in pubspec.yaml
In the main function create the localization delegate and start the app, wrapping it with LocalizedApp
If the assets directory for the localization files is different than the default one (assets/i18n
), you need to specify it:
Example MyApp:
Usage
Translate a string:
Translate with arguments;
Translate with pluralization:
JSON:
Change the language:
You can view the full example here:
https://github.com/bratan/flutter_translate/blob/master/example/lib/main.dart