From fbf9044867631ef878066f56e95740331c44bfcc Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 12 Jul 2018 08:21:59 -0700 Subject: [PATCH] Update translation descriptions: alertDialogLabel, searchFieldLabel (#19234) --- dev/tools/localizations_validator.dart | 19 +++++++++++++++++++ .../lib/src/l10n/material_en.arb | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dev/tools/localizations_validator.dart b/dev/tools/localizations_validator.dart index f73cfc19105..11a690955a1 100644 --- a/dev/tools/localizations_validator.dart +++ b/dev/tools/localizations_validator.dart @@ -8,6 +8,7 @@ import 'dart:io'; /// Sanity checking of the @foo metadata in the English translations, /// material_en.arb. /// +/// - For each foo, resource, there must be a corresponding @foo. /// - For each @foo resource, there must be a corresponding foo, except /// for plurals, for which there must be a fooOther. /// - Each @foo resource must have a Map value with a String valued @@ -23,6 +24,24 @@ String validateEnglishLocalizations(File file) { } final Map bundle = json.decode(file.readAsStringSync()); + + for (String resourceId in bundle.keys) { + if (resourceId.startsWith('@')) + continue; + + if (bundle['@$resourceId'] != null) + continue; + + bool checkPluralResource(String suffix) { + final int suffixIndex = resourceId.indexOf(suffix); + return suffixIndex != -1 && bundle['@${resourceId.substring(0, suffixIndex)}'] != null; + } + if (['Zero', 'One', 'Two', 'Few', 'Many', 'Other'].any(checkPluralResource)) + continue; + + errorMessages.writeln('A value was not specified for @$resourceId'); + } + for (String atResourceId in bundle.keys) { if (!atResourceId.startsWith('@')) continue; diff --git a/packages/flutter_localizations/lib/src/l10n/material_en.arb b/packages/flutter_localizations/lib/src/l10n/material_en.arb index 23b1a14025e..5a6d30872f0 100644 --- a/packages/flutter_localizations/lib/src/l10n/material_en.arb +++ b/packages/flutter_localizations/lib/src/l10n/material_en.arb @@ -197,12 +197,12 @@ }, "alertDialogLabel": "Alert", - "@dialogLabel": { + "@alertDialogLabel": { "description": "The audio announcement made when an AlertDialog is opened." }, "searchFieldLabel": "Search", - "@dialogLabel": { - "description": "Label indicating that a text field is a search field. This will be used as a hint text in the text field." - } + "@searchFieldLabel": { + "description": "Label indicating that a text field is a search field. This will be used as a hint text in the text field." + } }