PM-22634: Fix parsing of system language (#5353)

This commit is contained in:
David Perez
2025-06-12 20:47:12 +00:00
committed by GitHub
parent 5adccca823
commit 0ade60025c
2 changed files with 5 additions and 5 deletions
@@ -10,4 +10,4 @@ import java.util.Locale
val Locale.appLanguage: AppLanguage?
get() = AppLanguage
.entries
.find { it.localeName?.lowercase(this) == this.language.lowercase(this) }
.find { it.localeName?.lowercase(this) == this.toLanguageTag().lowercase(this) }
@@ -9,8 +9,8 @@ import java.util.Locale
class LocaleExtensionsTest {
@Test
fun `locale with Espanol language returns AppLanguage SPANISH`() {
val locale = Locale("es")
fun `locale with spanish language returns AppLanguage SPANISH`() {
val locale = Locale.forLanguageTag("es")
assertEquals(
AppLanguage.SPANISH,
locale.appLanguage,
@@ -19,7 +19,7 @@ class LocaleExtensionsTest {
@Test
fun `locale with GB english returns AppLanguage ENGLISH_BRITISH`() {
val locale = Locale("en-GB")
val locale = Locale.forLanguageTag("en-GB")
assertEquals(
AppLanguage.ENGLISH_BRITISH,
locale.appLanguage,
@@ -28,7 +28,7 @@ class LocaleExtensionsTest {
@Test
fun `locale with non existent app language returns null`() {
val locale = Locale("😅😅😅")
val locale = Locale.forLanguageTag("😅😅😅")
assertNull(locale.appLanguage)
}
}