Skip to content

Commit ea477d5

Browse files
authored
[gen_l10n] isCustomDateFormat accepts an actual boolean (#153439)
Fixes #153420 ## 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. - [ ] 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
1 parent 5d70d19 commit ea477d5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart

+3
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ class Placeholder {
283283
if (value == null) {
284284
return null;
285285
}
286+
if (value is bool) {
287+
return value;
288+
}
286289
if (value != 'true' && value != 'false') {
287290
throw L10nException(
288291
'The "$attributeName" value of the "$name" placeholder in message $resourceId '

packages/flutter_tools/test/general.shard/generate_localizations_test.dart

+22
Original file line numberDiff line numberDiff line change
@@ -1658,6 +1658,28 @@ import 'output-localization-file_en.dart' deferred as output-localization-file_e
16581658
expect(content, contains(r"DateFormat('asdf o\'clock', localeName)"));
16591659
});
16601660

1661+
testWithoutContext('handle arbitrary formatted date with actual boolean', () {
1662+
setupLocalizations(<String, String>{
1663+
'en': '''
1664+
{
1665+
"@@locale": "en",
1666+
"springBegins": "Spring begins on {springStartDate}",
1667+
"@springBegins": {
1668+
"description": "The first day of spring",
1669+
"placeholders": {
1670+
"springStartDate": {
1671+
"type": "DateTime",
1672+
"format": "asdf o'clock",
1673+
"isCustomDateFormat": true
1674+
}
1675+
}
1676+
}
1677+
}'''
1678+
});
1679+
final String content = getGeneratedFileContent(locale: 'en');
1680+
expect(content, contains(r"DateFormat('asdf o\'clock', localeName)"));
1681+
});
1682+
16611683
testWithoutContext('throws an exception when no format attribute is passed in', () {
16621684
expect(
16631685
() {

0 commit comments

Comments
 (0)