diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TLocale.java b/classlib/src/main/java/org/teavm/classlib/java/util/TLocale.java index 0dfce5e01f..945610744e 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TLocale.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TLocale.java @@ -278,7 +278,7 @@ public String toString() { public TString toLanguageTag() { StringBuilder result = new StringBuilder(); - result.append(languageCode); + result.append(languageCode.isEmpty() ? "und" : languageCode); if (!countryCode.isEmpty()) { result.append('-'); result.append(countryCode); diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java index c24bf72311..75122aa74c 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java @@ -328,6 +328,7 @@ public void convertsCaseLocaled() { assertEquals("İSTANBUL", turkish.toUpperCase(new Locale("tr", "TR"))); assertNotEquals(common.toUpperCase(Locale.US), turkish.toUpperCase(new Locale("tr", "TR"))); assertEquals(common.toUpperCase(Locale.US), common.toUpperCase(Locale.CANADA)); + assertEquals(common.toUpperCase(Locale.US), common.toUpperCase(Locale.ROOT)); } @Test diff --git a/tests/src/test/java/org/teavm/classlib/java/util/LocaleTest.java b/tests/src/test/java/org/teavm/classlib/java/util/LocaleTest.java index 90fea72da7..cc0a4e308a 100644 --- a/tests/src/test/java/org/teavm/classlib/java/util/LocaleTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/util/LocaleTest.java @@ -70,5 +70,6 @@ public void testLanguageTag() { assertEquals("zh-CN", Locale.SIMPLIFIED_CHINESE.toLanguageTag()); assertEquals("en-GB", Locale.UK.toLanguageTag()); assertEquals("en-US", Locale.US.toLanguageTag()); + assertEquals("und", Locale.ROOT.toLanguageTag()); } }