diff --git a/lib/web_ui/lib/src/ui/window.dart b/lib/web_ui/lib/src/ui/window.dart index d143c504696c4..f19432c4e0832 100644 --- a/lib/web_ui/lib/src/ui/window.dart +++ b/lib/web_ui/lib/src/ui/window.dart @@ -478,19 +478,17 @@ class Locale { int get hashCode => hashValues(languageCode, scriptCode, countryCode); @override - String toString() { + String toString() => _rawToString('_'); + + // TODO(yjbanov): implement to match flutter native. + String toLanguageTag() => _rawToString('-'); + + String _rawToString(String separator) { final StringBuffer out = StringBuffer(languageCode); - if (scriptCode != null) { - out.write('_$scriptCode'); - } - if (_countryCode != null) { - out.write('_$countryCode'); - } + if (scriptCode != null) out.write('$separator$scriptCode'); + if (_countryCode != null) out.write('$separator$countryCode'); return out.toString(); } - - // TODO(yjbanov): implement to match flutter native. - String toLanguageTag() => '_'; } /// The most basic interface to the host operating system's user interface.