mirror of
https://github.com/chenasraf/i18n.git
synced 2026-05-17 17:38:07 +00:00
refactor
This commit is contained in:
3
example/strings.i18n.yaml
Normal file
3
example/strings.i18n.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
strings:
|
||||
ok: OK
|
||||
cancel: CANCEL
|
||||
3
example/strings_de.i18n.yaml
Normal file
3
example/strings_de.i18n.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
strings:
|
||||
ok: OK
|
||||
cancel: STORNIEREN
|
||||
@@ -38,12 +38,16 @@ class YamlBasedBuilder implements Builder {
|
||||
final currentMap = loadYaml(contents) as YamlMap;
|
||||
final currentKeys = currentMap.allKeys;
|
||||
|
||||
final allFiles = await buildStep.findAssets(Glob('**.i18n.yaml')).toList();
|
||||
final pattern = Glob('**.i18n.yaml');
|
||||
final allFiles = await buildStep.findAssets(pattern).toList();
|
||||
final currentFileName = currentFile.pathSegments.last.replaceAll(
|
||||
'.i18n.yaml',
|
||||
'',
|
||||
);
|
||||
final defaultFile = allFiles.firstWhere(
|
||||
(e) {
|
||||
final name = e.uri.pathSegments.last.replaceAll(".i18n.yaml", "");
|
||||
|
||||
return !name.contains('_') && currentFile.pathSegments.last.replaceAll(".i18n.yaml", "").startsWith(name);
|
||||
final name = e.uri.pathSegments.last.replaceAll('.i18n.yaml', '');
|
||||
return !name.contains('_') && currentFileName.startsWith(name);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ dependencies:
|
||||
glob: ^2.0.0
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
lints: ^4.0.0
|
||||
test: ^1.16.8
|
||||
build_runner: ^2.0.0
|
||||
build_web_compilers: ^4.0.0
|
||||
|
||||
Reference in New Issue
Block a user