localTranslationExists method

Future<bool> localTranslationExists(
  1. String localeName, {
  2. bool ignoreCacheDuration = false,
})

Implementation

Future<bool> localTranslationExists(String localeName,
    {bool ignoreCacheDuration = false}) async {
  var translationFile = await getFileForLocale(localeName);

  if (!await translationFile.exists()) {
    return false;
  }

  // don't check file's age
  if (!ignoreCacheDuration) {
    var difference =
        DateTime.now().difference(await translationFile.lastModified());

    if (difference > (localCacheDuration)) {
      return false;
    }
  }

  return true;
}