diff --git a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.macos.kt b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.macos.kt index 83404652ee..55c6d6b032 100644 --- a/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.macos.kt +++ b/components/resources/library/src/macosMain/kotlin/org/jetbrains/compose/resources/ResourceEnvironment.macos.kt @@ -7,7 +7,12 @@ import platform.CoreGraphics.CGDisplayScreenSize import platform.Foundation.* internal actual fun getSystemEnvironment(): ResourceEnvironment { - val locale = NSLocale.currentLocale() + val locale = NSLocale.preferredLanguages.firstOrNull() + ?.let { NSLocale(it as String) } + ?: NSLocale.currentLocale + + val languageCode = locale.languageCode + val regionCode = locale.objectForKey(NSLocaleCountryCode) as? String val isDarkTheme = NSUserDefaults.standardUserDefaults.stringForKey("AppleInterfaceStyle") == "Dark" val dpi = NSScreen.mainScreen?.let { screen -> @@ -24,8 +29,8 @@ internal actual fun getSystemEnvironment(): ResourceEnvironment { } ?: 0 return ResourceEnvironment( - language = LanguageQualifier(locale.languageCode), - region = RegionQualifier(locale.regionCode.orEmpty()), + language = LanguageQualifier(languageCode), + region = RegionQualifier(regionCode.orEmpty()), theme = ThemeQualifier.selectByValue(isDarkTheme), density = DensityQualifier.selectByValue(dpi) )