writeTranslations method

  1. @override
void writeTranslations(
  1. Iterable<TranslatedMessage> usableTranslations,
  2. String locale
)
override

Write out the translated forms.

Implementation

@override
void writeTranslations(
    Iterable<TranslatedMessage> usableTranslations, String locale) {
  output.write('''
Map<String, dynamic> get messages => _constMessages;
''');

  var messages = usableTranslations
      .expand((translation) => translation.originalMessages);
  var map = <String, dynamic>{
    for (var original in messages)
      original.name: original.toJsonForLocale(locale)
  };

  output.write('  static const _constMessages = ');
  _writeValue(map);

  output.write(';\n\n');
  output.write('}');
}