Skip to content
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

Export strings for Compose Multiplatform #2397

Open
mauriziofaleo opened this issue Jul 2, 2024 · 7 comments
Open

Export strings for Compose Multiplatform #2397

mauriziofaleo opened this issue Jul 2, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task hacktoberfest

Comments

@mauriziofaleo
Copy link

mauriziofaleo commented Jul 2, 2024

Feature request
Strings for Compose Multiplatform need to be stored in an XML file encoded in a similar way to those used by Android, with some minor differences. For this reason, strings exported by Tolgee with the Android exporter are not immediately usable for mobile apps based on Compose Multiplatform and need some manual changes.

The only two differences I've identified are:

  • ' and " should not be escaped. If escaped as Android requires, the \ will be visible to the user. This point has been discussed in the Compose Multiplatform repository here and here, and they provided a confirmation regarding the differences of the two formats.
  • Positional arguments are exported for Android as %s without any indication of the argument number. For Compose Multiplatform, it should be %1$s, %2$s, etc. (source)

Describe the solution you'd like
I'd like to have a new export option called "Compose Multiplatform" which reuses the same implementation of the Android exporter, with the two differences I've mentioned before:

  • It does not escape ' and ".
  • It encodes the positional arguments with the position index.

Describe alternatives you've considered
The workaround I'm currently using is:

  • Manually replacing \' and \" with ' and " before importing the XML into the codebase.
  • Disabling the ICU Message Format so that I can manually handle the positional arguments in Tolgee.

Additional context
If you want to know more about Compose Multiplatform resources, you can check the official doc.

Thank you!

@JanCizmar JanCizmar self-assigned this Jul 6, 2024
@JanCizmar
Copy link
Contributor

Hey! Thanks! Will look into that!

@mauriziofaleo
Copy link
Author

Thank you Jan for considering it! I'm available for any kind of questions you might have!

@Nailik
Copy link

Nailik commented Jul 24, 2024

Another thing is the starting tag:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">

should only be
<resources>

for multiplatform

btw i would like this for android as well:

Positional arguments are exported for Android as %s without any indication of the argument number. For Compose Multiplatform, it should be %1$s, %2$s, etc. (source)

@JanCizmar
Copy link
Contributor

JanCizmar commented Jul 25, 2024

Hey! We will do following:

  • Add the positional for android too, since it removes the warning.
  • Remove the quoting logic for multiplatform files. Do I understand it correctly that there is no quoting logic for compose multiplatform resources?

@mauriziofaleo
Copy link
Author

Remove the quoting logic for multiplatform files. Do I understand it correctly that there is no quoting logic for compose multiplatform resources?

Exactly, on Compose Multiplatform we don't need to escape ' and ", so the logic needs to be removed.

@Nailik
Copy link

Nailik commented Aug 5, 2024

Another note, for multiplatform html tags should not be encoded as well.
You could test it with AnnotatedString.fromHtml(htmlString), there's also no need to wrap with cdata which removes the need of this android flag for multiplatform (or compose in general when using this approach)

@JanCizmar JanCizmar added enhancement New feature or request for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task labels Aug 20, 2024
@JanCizmar JanCizmar assigned Anty0 and unassigned JanCizmar Sep 16, 2024
@Anty0
Copy link
Collaborator

Anty0 commented Oct 11, 2024

Another note, for multiplatform html tags should not be encoded as well. You could test it with AnnotatedString.fromHtml(htmlString) ...

@Nailik Hi! Do you have some example files with this edge case? I'm trying to understand the difference. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request for-superday Tolgee SuperDay is a step part hiring process when candidate work on real task hacktoberfest
Projects
None yet
Development

No branches or pull requests

4 participants