LocalizationHelper constructor

LocalizationHelper(
  1. String pathGitsyaml
)

Implementation

LocalizationHelper(String pathGitsyaml) {
  final keyLocalization = 'localization';
  final keyArbDir = 'arb_dir';
  final keyTemplateArbFile = 'template_arb_file';
  final keyOutputLocalizationFile = 'output_localization_file';
  final keyOutputClass = 'output_class';
  final keyOutputDir = 'output_dir';
  final keyReplace = 'replace';

  final yaml = YamlHelper.loadFileYaml(pathGitsyaml);
  final Map<dynamic, dynamic> localization = yaml[keyLocalization];

  _abrDir = localization[keyArbDir] ?? '';
  _templateArbFile = localization[keyTemplateArbFile] ?? '';
  _outputLocalizationFile = localization[keyOutputLocalizationFile] ?? '';
  _outputClass = localization[keyOutputClass] ?? '';
  _outputDir = localization[keyOutputDir] ?? '';
  _replace = localization[keyReplace] == true;

  if (!exists(_abrDir)) {
    StatusHelper.failed(
        '''The '$keyArbDir' directory, 'LocalDirectory: '$_abrDir'', does not exist.
Make sure that the correct path was provided.''');
  }

  if (!exists('$_abrDir/$_templateArbFile')) {
    StatusHelper.failed(
        '''The '$keyTemplateArbFile' directory, 'LocalFile: '$_abrDir/$_templateArbFile'', does not exist.
Make sure that the correct path file was provided.''');
  }
}