JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16k stars 1.16k forks source link

Overriding string resources causes crashes or inelligible strings #5039

Closed chris6647 closed 2 months ago

chris6647 commented 3 months ago

Coming from the Android world, we're used to being able to define a String resource in a feature module, and then have the app override any string keys it may need to. This allows a feature to have defaults, which gets superseeded by the app, as long as they're in the same publicResClass.

Doing so in Compose Resources does not work, due to the offset and size parameters which match the initial StringResource in the feature. When we runtime try to resolve it, it may not match with the final string causing ineligble strings (/empty strings) to be returned, or even crashes if the base64 decoder fails with invalid chars.

Any chance for an implementation that supports this, or ideas for a workaround? So far I havn't been able to come up with anything that I can do from my end of the code. Had a hard time chosing between a bug report or enhancement request - but went with bug due to how the issues surface with wrong texts or crashes.

Similar problem as this issue https://github.com/JetBrains/compose-multiplatform/issues/4837 , but another use case, which will hopefully reconsider :)

terrakok commented 3 months ago

Yes, there is no and is not planned the overriding resources feature for now. Because accessors are being generated as code and compiled into Kotlin klibs. The android resources work different an ids are handled during a final app build. It is one of the reasons why android has own library format - AAR, as I understand.

chris6647 commented 2 months ago

At a glance, it seems like "just" parsing untill the line end, instead of offset and size, would work and would let you override string resources in the same nameSpaces. Would that be an option?

terrakok commented 2 months ago

No. You are not able to read bytes from a centre of the file without offset/size

chris6647 commented 2 months ago

Alright. Well I hope you guys will consider supporting it in the future :) Thanks for your prompt replies!

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.