1
0
mirror of https://github.com/krawieck/lemmur/ synced 2024-12-22 21:38:48 +01:00

Remove null fields when translating

This commit is contained in:
shilangyu 2021-02-28 16:47:03 +01:00
parent 0445f34250
commit f059e2186d

View File

@ -113,6 +113,22 @@ void portStrings(
}
Future<void> save(Map<String, Map<String, dynamic>> lemmurTranslations) async {
// remove null fields
// Vec<(language, key)>
final toRemove = <List<String>>[];
for (final translations in lemmurTranslations.entries) {
final language = translations.key;
for (final strings in translations.value.entries) {
if (strings.value == null) {
toRemove.add([language, strings.key]);
}
}
}
for (final rem in toRemove) {
lemmurTranslations[rem[0]].remove(rem[1]);
}
for (final language in lemmurTranslations.keys) {
await File('lib/l10n/$flutterIntlPrefix$language.arb')
.writeAsString(jsonEncode(lemmurTranslations[language]));