Skip to content

Commit

Permalink
Merge pull request #4 from icapps/improvement/isInTest
Browse files Browse the repository at this point in the history
Renamed isInTest to showLocalizationKeys
  • Loading branch information
vanlooverenkoen authored Mar 28, 2020
2 parents 9fa555e + be60cd2 commit ebb8af2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
14 changes: 8 additions & 6 deletions bin/icapps_translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Future<void> main(List<String> args) async {
Future<void> parsePubspec(File pubspecYaml) async {
final pubspecContent = pubspecYaml.readAsStringSync();
params = Params(pubspecContent);
print('Default language: ${params.defaultLanguage}');
print('Supported languages: ${params.languages}');
}

Future<void> _buildJson(String language) async {
Expand Down Expand Up @@ -116,9 +118,9 @@ void createLocalizationFile() {
' static Localization of(BuildContext context) => Localizations.of<Localization>(context, Localization);')
..writeln()
..writeln(
' static Future<Localization> load(Locale locale, {bool isInTest = false}) async {')
' static Future<Localization> load(Locale locale, {bool showLocalizationKeys = false}) async {')
..writeln(' final localizations = Localization();')
..writeln(' if (isInTest) {')
..writeln(' if (showLocalizationKeys) {')
..writeln(' return localizations;')
..writeln(' }')
..writeln(
Expand Down Expand Up @@ -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')
Expand All @@ -218,7 +220,7 @@ void createLocalizationDelegateFile() {
..writeln(' @override')
..writeln(' Future<Localization> 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')
Expand Down
4 changes: 0 additions & 4 deletions example/.flutter-plugins

This file was deleted.

1 change: 0 additions & 1 deletion example/.flutter-plugins-dependencies

This file was deleted.

2 changes: 1 addition & 1 deletion example/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MyApp extends StatelessWidget {
home: HomeScreen(),
),
),
create: (context) => kiwi.Container().resolve()..init(),
builder: (context) => kiwi.Container().resolve()..init(),
);
}
}
4 changes: 2 additions & 2 deletions example/lib/util/locale/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Localization {

static Localization of(BuildContext context) => Localizations.of<Localization>(context, Localization);

static Future<Localization> load(Locale locale, {bool isInTest = false}) async {
static Future<Localization> 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');
Expand Down
8 changes: 4 additions & 4 deletions example/lib/util/locale/localization_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class LocalizationDelegate extends LocalizationsDelegate<Localization> {

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
Expand All @@ -35,7 +35,7 @@ class LocalizationDelegate extends LocalizationsDelegate<Localization> {
@override
Future<Localization> load(Locale locale) async {
activeLocale = newLocale ?? locale;
return Localization.load(activeLocale, isInTest: isInTest);
return Localization.load(activeLocale, showLocalizationKeys: showLocalizationKeys);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -12,4 +12,4 @@ dependencies:
yaml: ^2.2.0

dev_dependencies:
test: ^1.12.0
test: ^1.14.2

0 comments on commit ebb8af2

Please sign in to comment.