diff --git a/packages/flutter_tools/lib/src/localizations/gen_l10n.dart b/packages/flutter_tools/lib/src/localizations/gen_l10n.dart index ee8427452b..7ee0964813 100644 --- a/packages/flutter_tools/lib/src/localizations/gen_l10n.dart +++ b/packages/flutter_tools/lib/src/localizations/gen_l10n.dart @@ -134,8 +134,8 @@ List generateMethodParameters( final Placeholder? localePlaceholder = localePlaceholders?[e.key]; if (localePlaceholder != null && placeholder.type != localePlaceholder.type) { throw L10nException( - 'The placeholder, ${placeholder.name}, has its "type" resource attribute set to ' - 'the "${localePlaceholder.type}" type in locale "$locale", but it is "${placeholder.type}" ' + 'For the message "${message.resourceId}" the placeholder "${placeholder.name}" has its "type" resource attribute set to ' + 'the type "${localePlaceholder.type}" in locale "$locale", but it is "${placeholder.type}" ' 'in the template placeholder. For compatibility with template placeholder, change ' 'the "type" attribute to "${placeholder.type}".', ); @@ -163,8 +163,8 @@ String generateDateFormattingLogic(Message message, LocaleInfo locale) { final String? placeholderFormat = placeholder.format; if (placeholderFormat == null) { throw L10nException( - 'The placeholder, ${placeholder.name}, has its "type" resource attribute set to ' - 'the "${placeholder.type}" type. To properly resolve for the right ' + 'For the message "${message.resourceId}" the placeholder "${placeholder.name}" has its "type" resource attribute set to ' + 'the type "${placeholder.type}" in locale "$locale". To properly resolve for the right ' '${placeholder.type} format, the "format" attribute needs to be set ' 'to determine which DateFormat to use. \n' "Check the intl library's DateFormat class constructors for allowed " @@ -176,8 +176,8 @@ String generateDateFormattingLogic(Message message, LocaleInfo locale) { (isCustomDateFormat == null || !isCustomDateFormat)) { if (placeholder.dateFormatParts.length > 1) { throw L10nException( - 'Date format "$placeholderFormat" for placeholder ' - '${placeholder.name} contains at least one invalid date format. ' + 'For the message "${message.resourceId}" the date format "$placeholderFormat" for placeholder ' + '${placeholder.name} contains at least one invalid date format in locale "$locale". ' 'Ensure all date formats joined by a "+" character have ' 'a corresponding DateFormat constructor.\n Check the intl ' "library's DateFormat class constructors for allowed date formats.", @@ -185,9 +185,9 @@ String generateDateFormattingLogic(Message message, LocaleInfo locale) { } throw L10nException( - 'Date format "$placeholderFormat" for placeholder ' + 'For the message "${message.resourceId}" the date format "$placeholderFormat" for placeholder ' '${placeholder.name} does not have a corresponding DateFormat ' - "constructor\n. Check the intl library's DateFormat class " + 'constructor in locale "$locale". Check the intl library\'s DateFormat class ' 'constructors for allowed date formats, or set "isCustomDateFormat" attribute ' 'to "true".', ); @@ -228,8 +228,8 @@ String generateNumberFormattingLogic(Message message, LocaleInfo locale) { final String? placeholderFormat = placeholder.format; if (!placeholder.hasValidNumberFormat || placeholderFormat == null) { throw L10nException( - 'Number format $placeholderFormat for the ${placeholder.name} ' - 'placeholder does not have a corresponding NumberFormat constructor.\n' + 'For the message "${message.resourceId}" the number format $placeholderFormat for the ${placeholder.name} ' + 'placeholder does not have a corresponding NumberFormat constructor in locale "$locale".\n' "Check the intl library's NumberFormat class constructors for allowed " 'number formats.', ); @@ -1406,9 +1406,9 @@ The plural cases must be one of "=0", "=1", "=2", "zero", "one", "two", "few", " // Check that formatType is a valid intl.DateFormat. if (!validDateFormats.contains(formatType.value)) { throw L10nParserException( - 'Date format "${formatType.value!}" for placeholder ' + 'For message "${message.resourceId}" the date format "${formatType.value!}" for placeholder ' '$identifierName does not have a corresponding DateFormat ' - "constructor\n. Check the intl library's DateFormat class " + 'constructor in locale "$locale"\n. Check the intl library\'s DateFormat class ' 'constructors for allowed date formats, or set "isCustomDateFormat" attribute ' 'to "true".', _inputFileNames[locale]!, diff --git a/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart b/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart index 4be34a3dd4..fd75febc5f 100644 --- a/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart +++ b/packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart @@ -505,7 +505,7 @@ class Message { } if (allPlaceholdersMap is! Map) { throw L10nException( - 'The "placeholders" attribute for message $resourceId, is not ' + 'The "placeholders" attribute for message "$resourceId", is not ' 'properly formatted. Ensure that it is a map with string valued keys.', ); } diff --git a/packages/flutter_tools/test/general.shard/generate_localizations_test.dart b/packages/flutter_tools/test/general.shard/generate_localizations_test.dart index 05a47e334f..fcd5f21e60 100644 --- a/packages/flutter_tools/test/general.shard/generate_localizations_test.dart +++ b/packages/flutter_tools/test/general.shard/generate_localizations_test.dart @@ -1779,6 +1779,8 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "springBegins"'), + contains('locale "en"'), contains('asdf'), contains('springStartDate'), contains('does not have a corresponding DateFormat'), @@ -1913,9 +1915,11 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "loggedIn"'), + contains('locale "en"'), contains('"foo+bar+baz"'), contains('lastLoginDate'), - contains('contains at least one invalid date format.'), + contains('contains at least one invalid date format'), ), ), ), @@ -1945,9 +1949,11 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "loggedIn"'), + contains('locale "en"'), contains('"yMd+Hm+"'), contains('lastLoginDate'), - contains('contains at least one invalid date format.'), + contains('contains at least one invalid date format'), ), ), ), @@ -1976,7 +1982,11 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e isA().having( (L10nException e) => e.message, 'message', - contains('the "format" attribute needs to be set'), + allOf( + contains('message "springBegins"'), + contains('locale "en"'), + contains('the "format" attribute needs to be set'), + ), ), ), ); @@ -2163,8 +2173,12 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e isA().having( (L10nException e) => e.message, 'message', - contains( - 'The placeholder, springStartDate, has its "type" resource attribute set to the "String" type in locale "ja", but it is "DateTime" in the template placeholder.', + allOf( + contains('placeholder "springStartDate"'), + contains('locale "ja"'), + contains( + '"type" resource attribute set to the type "String" in locale "ja", but it is "DateTime" in the template placeholder.', + ), ), ), ), @@ -2210,8 +2224,12 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e isA().having( (L10nException e) => e.message, 'message', - contains( - 'The placeholder, springStartDate, has its "type" resource attribute set to the "Object" type in locale "ja", but it is "DateTime" in the template placeholder.', + allOf( + contains('placeholder "springStartDate"'), + contains('locale "ja"'), + contains( + 'has its "type" resource attribute set to the type "Object" in locale "ja", but it is "DateTime" in the template placeholder.', + ), ), ), ), @@ -2366,6 +2384,8 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "courseCompletion"'), + contains('locale "en"'), contains('asdf'), contains('progress'), contains('does not have a corresponding NumberFormat'), @@ -2469,6 +2489,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "helloWorlds"'), contains('is not properly formatted'), contains('Ensure that it is a map with string valued keys'), ), @@ -2519,6 +2540,7 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e (L10nException e) => e.message, 'message', allOf( + contains('message "genderSelect"'), contains('is not properly formatted'), contains('Ensure that it is a map with string valued keys'), ), @@ -2632,8 +2654,12 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e } on L10nException { expect( logger.errorText, - contains( - 'Date format "yMMMMMd" for placeholder today does not have a corresponding DateFormat constructor', + allOf( + contains('message "datetime"'), + contains('locale "en"'), + contains( + 'date format "yMMMMMd" for placeholder today does not have a corresponding DateFormat constructor', + ), ), ); }