cacheEntries method

FutureOr<List<bool>?> cacheEntries(
  1. Map<String, String> entries,
  2. Map<String, String> translations,
  3. IntlLocale fromLocale,
  4. IntlLocale toLocale,
)

Cache translated entries (if cache is provided).

Implementation

FutureOr<List<bool>?> cacheEntries(
  Map<String, String> entries,
  Map<String, String> translations,
  IntlLocale fromLocale,
  IntlLocale toLocale,
) {
  var cache = this.cache;
  if (cache == null) return null;

  var results = entries.entries.map((e) {
    var k = e.key;
    var m = entries[k];
    if (m == null || m.trim().isEmpty) return false;
    var t = translations[k];
    if (t == null || t.trim().isEmpty) return false;
    return cache.store(k, m, t, fromLocale, toLocale);
  }).resolveAll();

  return results;
}