getL10nYamlSettings static method
Get project l10n.yaml settings
Implementation
static Future<L10nYaml> getL10nYamlSettings({bool verbose = false}) async {
if (verbose) {
print(grey('\tGetting file: l10n.yaml'));
}
final l10nYaml =
File(join(Directory.current.path, FileConstants.l10nYamlFile));
if (!await l10nYaml.exists()) {
throw Exception("File does not exist: ${l10nYaml.path}");
}
final content = l10nYaml.readAsStringSync();
final match =
RegExp(r'^arb-dir:\s*(.+)$', multiLine: true).firstMatch(content);
if (match == null) {
throw Exception('No arb-dir configuration in l10n.yaml file');
}
return L10nYaml(arbDir: match.group(1)!.trim());
}