From 443e1f97e6f19c7608fbb070122945498e3a6e3e Mon Sep 17 00:00:00 2001 From: Alexey Inkin Date: Mon, 26 Jun 2023 14:16:12 +0400 Subject: [PATCH 1/2] Static type for EasyLocalization.assetLoader (#524) --- CHANGELOG.md | 4 ++++ lib/src/easy_localization_app.dart | 27 +++++++++++++++++---------- pubspec.yaml | 21 ++++++++------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e3a0b7..3bc16e92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### [4.0.0] + +- **BREAKING:** `EasyLocalization.assetLoader` is now `AssetLoader` (was dynamic). + ### [3.0.2] - support intl 18 diff --git a/lib/src/easy_localization_app.dart b/lib/src/easy_localization_app.dart index e5c9ec8c..9b6db7d3 100644 --- a/lib/src/easy_localization_app.dart +++ b/lib/src/easy_localization_app.dart @@ -65,8 +65,7 @@ class EasyLocalization extends StatefulWidget { /// Class loader for localization files. /// You can use custom loaders from [Easy Localization Loader](https://github.com/aissat/easy_localization_loader) or create your own class. /// @Default value `const RootBundleAssetLoader()` - // ignore: prefer_typing_uninitialized_variables - final assetLoader; + final AssetLoader assetLoader; /// Save locale in device storage. /// @Default value true @@ -195,9 +194,12 @@ class _EasyLocalizationProvider extends InheritedWidget { // _EasyLocalizationDelegate get delegate => parent.delegate; - _EasyLocalizationProvider(this.parent, this._localeState, - {Key? key, required this.delegate}) - : currentLocale = _localeState.locale, + _EasyLocalizationProvider( + this.parent, + this._localeState, { + Key? key, + required this.delegate, + }) : currentLocale = _localeState.locale, super(key: key, child: parent.child) { EasyLocalization.logger.debug('Init provider'); } @@ -245,8 +247,10 @@ class _EasyLocalizationDelegate extends LocalizationsDelegate { /// * use only the lang code to generate i18n file path like en.json or ar.json // final bool useOnlyLangCode; - _EasyLocalizationDelegate( - {this.localizationController, this.supportedLocales}) { + _EasyLocalizationDelegate({ + this.localizationController, + this.supportedLocales, + }) { EasyLocalization.logger.debug('Init Localization Delegate'); } @@ -260,9 +264,12 @@ class _EasyLocalizationDelegate extends LocalizationsDelegate { await localizationController!.loadTranslations(); } - Localization.load(value, - translations: localizationController!.translations, - fallbackTranslations: localizationController!.fallbackTranslations); + Localization.load( + value, + translations: localizationController!.translations, + fallbackTranslations: localizationController!.fallbackTranslations, + ); + return Future.value(Localization.instance); } diff --git a/pubspec.yaml b/pubspec.yaml index fdf6e127..9fdfa709 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,28 +1,23 @@ name: easy_localization -description: Easy and Fast internationalizing and localization your Flutter Apps, this package simplify the internationalizing process . +description: Easy and fast internationalizing and localization your Flutter Apps, this package simplifies the internationalizing process. # author: AISSAT abdelwahab homepage: https://github.com/aissat/easy_localization issue_tracker: https://github.com/aissat/easy_localization/issues -# publish_to: none -version: 3.0.2 +version: 4.0.0-dev environment: sdk: '>=2.12.0 <4.0.0' dependencies: - flutter: - sdk: flutter - shared_preferences: '>=2.0.0 <3.0.0' - intl: '>=0.17.0-0 <=0.18.1' args: ^2.3.1 - path: ^1.8.1 easy_logger: ^0.0.2 - flutter_localizations: - sdk: flutter - + flutter: { sdk: flutter } + flutter_localizations: { sdk: flutter } + intl: '>=0.17.0-0 <=0.18.1' + path: ^1.8.1 + shared_preferences: '>=2.0.0 <3.0.0' dev_dependencies: - flutter_test: - sdk: flutter flutter_lints: ^2.0.1 + flutter_test: { sdk: flutter } From d8576100058ff2e823ab30bf2139c299ea8d642f Mon Sep 17 00:00:00 2001 From: Alexey Inkin Date: Tue, 27 Jun 2023 16:49:59 +0400 Subject: [PATCH 2/2] Explain an earlier deprecation (#524) --- lib/src/utils.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/utils.dart b/lib/src/utils.dart index eedf0e2e..6e82ac7c 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -24,7 +24,7 @@ Locale localeFromString(String localeString) { } /// Convert [locale] to Srting with custom [separator] -@Deprecated('Deprecated on Easy Localization 3.0') +@Deprecated('Deprecated on Easy Localization 3.0, use Locale.toStringWithSeparator extension method.') String localeToString(Locale locale, {String separator = '_'}) { return locale.toString().split('_').join(separator); }