Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/ui/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ void _updateWindowMetrics(double devicePixelRatio,

typedef String LocaleClosure();

String _localeClosure() => window._locale.toString();
String _localeClosure() {
const String enUS = 'en_US';
final String locale = window?._locale?.toString() ?? enUS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?. wasn't used before - seems like we could do without them here. If we do need then, then you should check for null below.

return (locale == '_') ? enUS : locale;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it _ in the first place versus just being null or the empty string? Are the tests that failed valid in wanting it to start out as _?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Locale is initialized from the engine with empty strings for the language and the country codes. Some logic in the tests and/or the framework appears to rely on that behavior. Whether that makes sense or not, I wouldn't venture to guess.

}

LocaleClosure _getLocaleClosure() => _localeClosure;

Expand Down