generateTemplateFile method

  1. @override
String generateTemplateFile(
  1. TranslationTemplate catalog,
  2. {bool suppressMetaData = false,
  3. bool includeSourceText = true}
)
override

Implementation

@override
String generateTemplateFile(
  TranslationTemplate catalog, {
  bool suppressMetaData = false,
  bool includeSourceText = true,
}) {
  final allMessages = <String, dynamic>{
    if (catalog.defaultLocale != null) "@@locale": catalog.defaultLocale,
    if (catalog.lastModified != null)
      "@@last_modified": catalog.lastModified.toIso8601String(),
  };

  catalog.messages.forEach((k, v) {
    final messages = Map<String, dynamic>.from(toARB(v,
        supressMetadata: suppressMetaData,
        includeSourceText: includeSourceText));
    allMessages.addAll(messages);
  });

  final encoder = JsonEncoder.withIndent('  ');
  return encoder.convert(allMessages);
}