tr method

String tr(
  1. {List<String>? args,
  2. Map<String, String>? namedArgs,
  3. String? gender,
  4. BuildContext? context}
)

Main function for translate your language keys key Localization key BuildContext The location in the tree where this widget builds args List of localized strings. Replaces {} left to right namedArgs Map of localized strings. Replaces the name keys {key_name} according to its name gender Gender switcher. Changes the localized string based on gender string

Example:

{
   "msg":"{} are written in the {} language",
   "msg_named":"Easy localization is written in the {lang} language",
   "msg_mixed":"{} are written in the {lang} language",
   "gender":{
      "male":"Hi man ;) {}",
      "female":"Hello girl :) {}",
      "other":"Hello {}"
   }
}
Text('msg').tr(args: ['Easy localization', 'Dart']), // args
Text('msg_named').tr(namedArgs: {'lang': 'Dart'}),   // namedArgs
Text('msg_mixed').tr(args: ['Easy localization'], namedArgs: {'lang': 'Dart'}), // args and namedArgs
Text('gender').tr(gender: _gender ? "female" : "male"), // gender

Implementation

String tr({
  List<String>? args,
  Map<String, String>? namedArgs,
  String? gender,
  BuildContext? context,
}) =>
    ez.tr(this,
        context: context, args: args, namedArgs: namedArgs, gender: gender);