New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stringResource filters the default when getting the resource path #4571
Comments
In a case when you provide region's specific localizations, you are suppose to provide default localization without the region (in your case The same loggic is being used in the Android: |
Okay, thank you very much, it's my mistake, i'm following the Android Resource approach, whose default string resource doesn't need to qualify "-zh" to values. |
Oh! I guess I got your point: the android logic works with a locale+region as a single qualifier. I need a time to think about it |
Yes, since I only use zh, changing values to values-zh would have solved my case, but if there are multiple locales, lazy people like me would be more inclined to just create one default values for all locales. |
Same issue here. Strings in |
…gion or default language match (#4577) We need to filter by language and region together because there is slightly different logic: 1) if there is the exact match language+region then use it 2) if there is the language WITHOUT region match then use it 3) in other cases use items WITHOUT language and region qualifiers at all Given resources: values values-en-rUS values-de Filter results: "en" -> values "en-US" -> values-en-rUS "en-GB" -> values "de-IT" -> values-de fixes #4571
Describe the bug
Hey, I've found that on Android or Desktop, in
org.jetbrains.compose.resources.ResourcesEnvironment.kt
, the extension functiongetPathByEnvironment
ofResource
class will filter the defaultStringResource
(values/strings.xml) byfilterBy
. For example, I have default (itsqualifiers
is an emptySet
), zh-HK, zh-TW and zh-MO inStringResource.items
, and the platform language is zh-CN, the firstfilterBy
will filter out zh-HK, zh-TW, and zh-MO, and the secondfilterBy
will return an emptyList
because CN cannot be found, and finally cause an exception, instead of returning the default path. I have given a modification (it works in this case) in screenshot 2 below.(My English is poor, wish I expressed it clearly enough.)
Affected platforms
Versions
Screenshots
The text was updated successfully, but these errors were encountered: