From be60cd2fc31be80604b539cb6785445ca5467666 Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Sat, 28 Mar 2020 14:11:51 +0100 Subject: [PATCH] Renamed isInTest to showLocalizationKeys this way it is more clear what this boolean does. BREAKING CHANGE => 2.0.0 --- CHANGELOG.md | 5 +++++ bin/icapps_translations.dart | 14 ++++++++------ example/.flutter-plugins | 4 ---- example/.flutter-plugins-dependencies | 1 - example/lib/app.dart | 2 +- example/lib/util/locale/localization.dart | 4 ++-- example/lib/util/locale/localization_delegate.dart | 8 ++++---- pubspec.yaml | 4 ++-- 8 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 example/.flutter-plugins delete mode 100644 example/.flutter-plugins-dependencies diff --git a/CHANGELOG.md b/CHANGELOG.md index 4006a77..23eb554 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [2.0.0] - 2020-02-10 +### Breaking +-isInTest => showLocalizationKeys + Behaviour is still the same. + ## [1.0.1] - 2020-02-18 ### Removed - Removed ⚠ before and after keys. diff --git a/bin/icapps_translations.dart b/bin/icapps_translations.dart index 8941801..d7c98d6 100644 --- a/bin/icapps_translations.dart +++ b/bin/icapps_translations.dart @@ -45,6 +45,8 @@ Future main(List args) async { Future parsePubspec(File pubspecYaml) async { final pubspecContent = pubspecYaml.readAsStringSync(); params = Params(pubspecContent); + print('Default language: ${params.defaultLanguage}'); + print('Supported languages: ${params.languages}'); } Future _buildJson(String language) async { @@ -116,9 +118,9 @@ void createLocalizationFile() { ' static Localization of(BuildContext context) => Localizations.of(context, Localization);') ..writeln() ..writeln( - ' static Future load(Locale locale, {bool isInTest = false}) async {') + ' static Future load(Locale locale, {bool showLocalizationKeys = false}) async {') ..writeln(' final localizations = Localization();') - ..writeln(' if (isInTest) {') + ..writeln(' if (showLocalizationKeys) {') ..writeln(' return localizations;') ..writeln(' }') ..writeln( @@ -201,14 +203,14 @@ void createLocalizationDelegateFile() { ..writeln() ..writeln(' Locale newLocale;') ..writeln(' Locale activeLocale;') - ..writeln(' bool isInTest;') + ..writeln(' bool showLocalizationKeys;') ..writeln() ..writeln( - ' LocalizationDelegate({this.newLocale, this.isInTest = false}) {') + ' LocalizationDelegate({this.newLocale, this.showLocalizationKeys = false}) {') ..writeln(' if (newLocale != null) {') ..writeln(' activeLocale = newLocale;') ..writeln(' }') - ..writeln(' isInTest ??= false;') + ..writeln(' showLocalizationKeys ??= false;') ..writeln(' }') ..writeln() ..writeln(' @override') @@ -218,7 +220,7 @@ void createLocalizationDelegateFile() { ..writeln(' @override') ..writeln(' Future load(Locale locale) async {') ..writeln(' activeLocale = newLocale ?? locale;') - ..writeln(' return Localization.load(activeLocale, isInTest: isInTest);') + ..writeln(' return Localization.load(activeLocale, showLocalizationKeys: showLocalizationKeys);') ..writeln(' }') ..writeln() ..writeln(' @override') diff --git a/example/.flutter-plugins b/example/.flutter-plugins deleted file mode 100644 index fd0e3c3..0000000 --- a/example/.flutter-plugins +++ /dev/null @@ -1,4 +0,0 @@ -# This is a generated file; do not edit or check into version control. -shared_preferences=/Users/hannesvandenberghe/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.6+1/ -shared_preferences_macos=/Users/hannesvandenberghe/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+5/ -shared_preferences_web=/Users/hannesvandenberghe/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+3/ diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies deleted file mode 100644 index ee15714..0000000 --- a/example/.flutter-plugins-dependencies +++ /dev/null @@ -1 +0,0 @@ -{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]}]} \ No newline at end of file diff --git a/example/lib/app.dart b/example/lib/app.dart index e00c7d9..2a95e60 100755 --- a/example/lib/app.dart +++ b/example/lib/app.dart @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget { home: HomeScreen(), ), ), - create: (context) => kiwi.Container().resolve()..init(), + builder: (context) => kiwi.Container().resolve()..init(), ); } } diff --git a/example/lib/util/locale/localization.dart b/example/lib/util/locale/localization.dart index 4bbb2ed..34a28b5 100644 --- a/example/lib/util/locale/localization.dart +++ b/example/lib/util/locale/localization.dart @@ -12,9 +12,9 @@ class Localization { static Localization of(BuildContext context) => Localizations.of(context, Localization); - static Future load(Locale locale, {bool isInTest = false}) async { + static Future load(Locale locale, {bool showLocalizationKeys = false}) async { final localizations = Localization(); - if (isInTest) { + if (showLocalizationKeys) { return localizations; } final jsonContent = await rootBundle.loadString('assets/locale/${locale.languageCode}.json'); diff --git a/example/lib/util/locale/localization_delegate.dart b/example/lib/util/locale/localization_delegate.dart index 4a68710..fd9b944 100644 --- a/example/lib/util/locale/localization_delegate.dart +++ b/example/lib/util/locale/localization_delegate.dart @@ -20,13 +20,13 @@ class LocalizationDelegate extends LocalizationsDelegate { Locale newLocale; Locale activeLocale; - bool isInTest; + bool showLocalizationKeys; - LocalizationDelegate({this.newLocale, this.isInTest = false}) { + LocalizationDelegate({this.newLocale, this.showLocalizationKeys = false}) { if (newLocale != null) { activeLocale = newLocale; } - isInTest ??= false; + showLocalizationKeys ??= false; } @override @@ -35,7 +35,7 @@ class LocalizationDelegate extends LocalizationsDelegate { @override Future load(Locale locale) async { activeLocale = newLocale ?? locale; - return Localization.load(activeLocale, isInTest: isInTest); + return Localization.load(activeLocale, showLocalizationKeys: showLocalizationKeys); } @override diff --git a/pubspec.yaml b/pubspec.yaml index 4111fd1..f01c6e2 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: icapps_translations description: Dart tool to generate flutter translations code from the icapps translations tool -version: 1.0.1 +version: 2.0.0 homepage: https://github.com/icapps/flutter-icapps-translations environment: @@ -12,4 +12,4 @@ dependencies: yaml: ^2.2.0 dev_dependencies: - test: ^1.12.0 + test: ^1.14.2