TranslationConfig.fromYaml constructor

TranslationConfig.fromYaml(
  1. String content,
  2. String fileName
)

Implementation

factory TranslationConfig.fromYaml(
  String content,
  String fileName,
) {
  final yaml = loadYaml(content);

  if (yaml == null) {
    throw '$fileName is empty';
  }

  final node = yaml['intl_translation'];
  if (node == null) {
    throw '$fileName does not contain a intl_translation';
  }

  return TranslationConfig(
    projectName: node['project_name'],
    outputDir: node['output_dir'],
    format: node['format'],
    defaultLocale: node['default_locale'],
    sourceFiles: List<String>.from(node['sources']),
    translationFiles: List<String>.from(node['translations']),
  );
}