diff --git a/example/locales/ar.json b/example/locales/ar.json deleted file mode 100644 index b82805c..0000000 --- a/example/locales/ar.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "مرحبًا": "مرحبًا يا صديقي" -} \ No newline at end of file diff --git a/example/locales/de.json b/example/locales/de.json deleted file mode 100644 index a781c4f..0000000 --- a/example/locales/de.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hallo": "hallo mein Freund" -} \ No newline at end of file diff --git a/example/locales/en.json b/example/locales/en.json deleted file mode 100644 index 41a91d8..0000000 --- a/example/locales/en.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hello": "hello my friend" -} \ No newline at end of file diff --git a/example/locales/es.json b/example/locales/es.json deleted file mode 100644 index 8245488..0000000 --- a/example/locales/es.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hola": "hola mi amigo" -} \ No newline at end of file diff --git a/example/locales/fr.json b/example/locales/fr.json deleted file mode 100644 index 04a556e..0000000 --- a/example/locales/fr.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hello": "bonjour mon ami" -} \ No newline at end of file diff --git a/example/locales/ge.json b/example/locales/ge.json deleted file mode 100644 index 15eaa02..0000000 --- a/example/locales/ge.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "hello": "გამარჯობა მეგობრებო" -} \ No newline at end of file diff --git a/example/locales/zh.json b/example/locales/zh.json deleted file mode 100644 index 0ca7efd..0000000 --- a/example/locales/zh.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "你好": "你好,我的朋友" -} \ No newline at end of file diff --git a/lib/src/commands/config_command/sub_commands/validate_command.dart b/lib/src/commands/config_command/sub_commands/validate_command.dart index 4f24ccc..4ce8f2a 100644 --- a/lib/src/commands/config_command/sub_commands/validate_command.dart +++ b/lib/src/commands/config_command/sub_commands/validate_command.dart @@ -80,8 +80,6 @@ class ConfigValidateCommand extends Command { ConfigFile _controllerFromFile({ required List configFiles, }) { - print(configFiles.length); - if (configFiles.isEmpty) { logger ..info( diff --git a/lib/src/etc/controllers/config_file.dart b/lib/src/etc/controllers/config_file.dart index 185240c..0589dc1 100644 --- a/lib/src/etc/controllers/config_file.dart +++ b/lib/src/etc/controllers/config_file.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:args/src/arg_results.dart'; +import 'package:langsync/src/etc/extensions.dart'; import 'package:mason_logger/mason_logger.dart'; import 'package:meta/meta.dart'; @@ -29,7 +30,7 @@ abstract class ConfigFile { static Iterable get configFilesInCurrentDir => Directory('.').listSync().where( (file) { - final fileName = file.path.split('/').last; + final fileName = file.fileNameOnly; return _controllers.containsKey(fileName); }, @@ -39,9 +40,9 @@ abstract class ConfigFile { File get configFileRef; - String get configFileExtension => configFileRef.path.split('.').last; + // String get configFileExtension => configFileRef.path.split('.').last; - String get configFileName => configFileRef.path.split('/').last; + String get configFileName => configFileRef.fileNameOnly; Future> parsed(); @@ -154,8 +155,8 @@ abstract class ConfigFile { Future writeNewConfig(Map config); - static ConfigFile controllerFromFile(FileSystemEntity first) { - final fileName = first.path.split('/').last; + static ConfigFile controllerFromFile(FileSystemEntity file) { + final fileName = file.fileNameOnly; return _controllers[fileName]!; } diff --git a/lib/src/etc/extensions.dart b/lib/src/etc/extensions.dart index be0c02a..fa07c60 100644 --- a/lib/src/etc/extensions.dart +++ b/lib/src/etc/extensions.dart @@ -1,9 +1,11 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:math'; import 'package:langsync/src/etc/models/config.dart'; import 'package:langsync/src/etc/utils.dart'; import 'package:mason_logger/mason_logger.dart'; +import 'package:path/path.dart'; final randomframesToUse = utils.randomLoadingFrames(); @@ -108,3 +110,7 @@ extension DateExt on DateTime { return '${day.toString().padLeft(2, '0')}/${month.toString().padLeft(2, '0')}/${year.toString().padLeft(2, '0')} ${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}:${second.toString().padLeft(2, '0')}'; } } + +extension FileSystemEntityExt on FileSystemEntity { + String get fileNameOnly => basename(path); +} diff --git a/lib/src/etc/networking/client_boilerplate.dart b/lib/src/etc/networking/client_boilerplate.dart index 26a89c3..4814edc 100644 --- a/lib/src/etc/networking/client_boilerplate.dart +++ b/lib/src/etc/networking/client_boilerplate.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:http/http.dart' as http; +import 'package:langsync/src/etc/extensions.dart'; import 'package:langsync/src/etc/utils.dart'; class NetClientBoilerPlate { @@ -53,7 +54,7 @@ class NetClientBoilerPlate { final multipartFile = http.MultipartFile.fromBytes( key, value.readAsBytesSync(), - filename: value.path.split('/').last, + filename: value.fileNameOnly, ); request.files.add(multipartFile); diff --git a/pubspec.yaml b/pubspec.yaml index d7fda43..e6573f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: http: ^1.1.0 mason_logger: ^0.2.4 meta: ^1.11.0 + path: ^1.8.3 pub_updater: ^0.3.0 yaml: ^3.1.2