loadTranslations static method

Future<Map<String, Map<String, String>>> loadTranslations(
  1. String assetsTranslationsPath, [
  2. List<Locale>? supportedLocales
])

assetsTranslationsPath path to the folder, inside assets, which contains translation files. With supportedLocales you can provide which locales should be loaded. If you do not provide this, all files inside that folder are loaded.

Implementation

static Future<Map<String, Map<String, String>>> loadTranslations(
    String assetsTranslationsPath,
    [List<Locale>? supportedLocales]) async {
  if (assetsTranslationsPath.isEmpty) {
    throw Exception("Given assetsTranslationsPath is empty!");
  }

  final repository = TranslationFileRepositoryImpl(assetsTranslationsPath);

  if (null != supportedLocales && supportedLocales.isNotEmpty) {
    return loadTranslationsForLocales(supportedLocales, repository);
  } else {
    return loadAllTranslationsFromAssets(assetsTranslationsPath, repository);
  }
}