[Gen-l10n] Add Message.resourceId and locale to all L10nException error messages (#163654)

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

I've had this problem today
https://github.com/flutter/flutter/issues/163627 where the generator
would display me this error message:

> Error: The placeholder, count, has its "type" resource attribute set
to the "null" type in locale "en", but it is "num" in the template
placeholder. For compatibility with template placeholder, change the
"type" attribute to "num".

Unfortunately this isn't really actionable as it omits to which message
it's actually referring to!

So I added the id of the message to all error message and the locale of
the message to all messages that hadn't had it already.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Bent Hillerkus
2025-04-01 17:07:03 +02:00
committed by GitHub
parent 70cd54c3fd
commit 0befaaafc9
3 changed files with 48 additions and 22 deletions

View File

@@ -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<L10nException>().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<L10nException>().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<L10nException>().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',
),
),
);
}