Closed Thomas-Vos closed 3 months ago
There are some differences with string parsing with compose when compared to official string resources on Android
Yes. It is by design
1) You are suppose to use Res class for that and a slightly different format
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#string-templates
2) Because you do have new lines and \n
symbols in you text
https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-images-resources.html#simple-strings
3) Because you are not suppose to use backslashes for that, just have a text in a clean form
Alright, but in my project the strings are imported by translation services. They use the Android format. That compose works differently does make it more difficult.
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.
Describe the bug There are some differences with string parsing with compose when compared to official string resources on Android:
1. Format args
It is possible to pass format args to
org.jetbrains.compose.resources.stringResource
. Great, but it doesn't work with:%s
%d
On Android this does work. Example string:
Usage:
Expected output:
2. Newlines
Example string:
Expected output:
There are additional newlines in the output which is incorrect when compared to Android. On Android, a simple newline (not
\n
but literally a new line) is ignored.3. Backslashes
Here are two strings:
On Android the output would be:
But with compose the output still contains the backwards slashes.
Affected platforms All
Versions
Expected behavior Same behaviour as official Android strings.