Open tiloc opened 3 years ago
What API in the intl
library requires this format?
@goderbauer Numerous, such as the constructor for NumberFormatter: https://pub.dev/packages/intl#number-formatting-and-parsing
var f = NumberFormat('###.0#', 'en_US');
print(f.format(12.345));
==> 12.34
or DateFormat:
DateFormat.yMd('en_US').parse('1/10/2012');
DateFormat('Hms', 'en_US').parse('14:23:01');
or setting the global locale:
Intl.defaultLocale = 'pt_BR';
All these examples taken from their examples page.
According to the documentation, Locale.toString() is only to be used for debugging: https://api.flutter.dev/flutter/dart-ui/Locale/toString.html
The proposed alternative is
toLanguageTag()
.However, toString uses underscores, whereas toLanguageTag uses hyphens as separators.
The popular Dart 'intl' library requires stringified locales with underscores, as returned by toString.
I am therefore proposing that either toString() becomes officially usable for non-debugging production use. Or the toLanguageTag method gains a 'separator' parameter which defaults to '-'.