At the time of writing, the “basic” i18n approach in Flutter is complicated and heavyweight. That’s why I decided to start my own library: fast_i18n
Please don’t forget to include the build_runner. You will need that because the JSON files will be translated at compile-time!
# pubspec.yaml
dependencies:
fast_i18n: ^1.4.0 # please look up the latest version on pub.dev
dev_dependencies:
build_runner: any
Now lets add some strings. Just make sure that they are inside the lib directory and all in one common package like lib/i18n/strings.i18n.json
{
"hello": "Hello $name",
"save": "Save",
"login": {
"success": "Logged in successfully",
"fail": "Logged in failed"
}
}
#localization #simple #flutter