json_translation

Last updated:

0 purchases

json_translation Image
json_translation Images
Add to Cart

Description:

json translation

JSON translations package for Flutter applications.
Features #

Use JSON file to translate your application

Getting started #
flutter pub add json_translation
copied to clipboard
Usage #
See example.
Add a JSON file per language #
Add a JSON file per language you support in the locales path and describe it in your pubspec.yaml
The locale path must be ./locales
flutter:
assets:
- locales/
copied to clipboard
Use one JSON file/object per language to represent the key:String/value:String pairs for the localization of your application.
Exemple project tree
The JSON file name must match exactly with a language code described in supportedLocales.
lib/
locales/
en.json
fr.json
copied to clipboard
Example JSON file
// en.json
{
"hello-world": "Hello World."
}

// fr.json
{
"hello-world": "Bonjour à tous."
}
copied to clipboard
Exemple MaterialApp
Add JsonTranslation.delegate in the localizationsDelegates of your MaterialApp
MaterialApp(
localizationsDelegates: const [
JsonTranslation.delegate,
...GlobalMaterialLocalizations.delegates,
],
supportedLocales: const [
Locale('en'),
Locale('fr'),
],
);
copied to clipboard
Exemple
Use the $() function translate keywords
import 'package:json_translation/json_translation.dart';

Container(
child: Text($("hello-world"))
)
copied to clipboard
Contributing #
You have a lot of options to contribute to this project ! You can :

Fork on Github
Submit a bug report.
Donate to the Developper

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.