contentForLocale method
Generate a string that contains the dart code
with the translations
in locale
.
Implementation
String contentForLocale(
String basicLocale,
Iterable<TranslatedMessage> translations,
) {
clearOutput();
var locale = Message.escapeString(Intl.canonicalizedLocale(basicLocale));
output.write(prologue(locale));
// Exclude messages with no translation and translations with no matching
// original message (e.g. if we're using some messages from a larger
// catalog)
var usableTranslations = translations
.where((translation) => translation.originalMessages.isNotEmpty)
.toList();
for (var translation in usableTranslations) {
for (var original in translation.originalMessages) {
original.addTranslation(locale, translation.message);
}
}
usableTranslations.sort((a, b) =>
a.originalMessages.first.name.compareTo(b.originalMessages.first.name));
writeTranslations(usableTranslations, locale);
return '$output';
}