readModuleTranslationFile method

Future<void> readModuleTranslationFile(
  1. Locale locale,
  2. String package
)

readModuleTranslationFile() Permits to load the content of the matching translation file asset from a given locale of a module.

Implementation

Future<void> readModuleTranslationFile(Locale locale, String package) async {
  var path = '''$package'''
      '''${KareeConstants.kApplicationLocalizationRessourcDir}'''
      '''/${locale.languageCode.toLowerCase()}'''
      '''${locale.countryCode != null ? '_${locale.countryCode!.toLowerCase()}' : ''}.json''';
  String translationString = await loadConfig(path);
  try {
    if (translation == null) {
      translation = jsonDecode(translationString);
    } else {
      translation!.addAll(jsonDecode(translationString));
    }
    // ignore: empty_catches
  } catch (e) {}
}