add method
Implementation
void add(Json data) {
const localeId = '@@locale';
final String? locale = data[localeId];
if (locale == null) {
throw ArbImportException('Arb must be contain $localeId element');
}
data.remove(localeId);
data.removeWhere((key, value) => key.startsWith('@@'));
_store[locale] = {};
data.keys.fold(_store[locale], (ac, key) {
final isExtra = key.startsWith('@');
final id = isExtra ? key.substring(1) : key;
if (ac[id] == null) {
ac[id] = {};
}
if (isExtra) {
final Map<String, dynamic> extra = data[key];
for (final extraKey in extra.keys) {
ac[id][extraKey] = extra[extraKey];
}
} else {
ac[id]['value'] = data[id];
}
return ac;
});
}