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

Apple strings with integer placeholders %d and %i do not work properly #2818

Open
algoroq opened this issue Jan 8, 2025 · 3 comments
Open

Comments

@algoroq
Copy link

algoroq commented Jan 8, 2025

Apple strings containing placeholders for integers (%d and %i) cannot be imported correctly. Additionally, the export is incorrect, as the % character is doubled.

It is possible to disable substitution for universal ICU placeholders during import and to turn off universal ICU placeholders in the project settings to ensure correct export behavior.

Reproduce

  1. Import this file into a new project on tolgee.io, leaving the default settings on import.
"test_placeholder_i" = "placeholder i: %i";
"test_placeholder_d" = "placeholder d: %d";
  1. Export the project as APPLE_STRING while keeping the default settings. I get this
"test_placeholder_d" = "placeholder d: %%d";
"test_placeholder_i" = "placeholder i: %%i";

It can't be used for doubled %.

Expected export

"test_placeholder_i" = "placeholder i: %i";
"test_placeholder_d" = "placeholder d: %d";

Versions and environment

  • Environment: current tolgee.io

Additional context
Other placeholder as %e, %@, %f works properly.

@JanCizmar
Copy link
Contributor

JanCizmar commented Jan 9, 2025

Hello!

Thanks for reaching out. This happens, because the %i and %d parameters are not converted to ICU, since they are not supported.

https://docs.tolgee.io/platform/formats/apple_strings

This means that the parameters are imported as they are. (With %) sign. While exporting with Tolgee Universal ICU placeholders, the % has to be escaped (to %%).

@Anty0 Do you have an idea, how to ensure that we import and export the same data for apple even in these cases? We cannot simply convert %d and %i to ICU {0, number}, because then we would loose the information about the source type.

Maybe we can keep the apple type for each imported parameter stored in custom data.

@algoroq
Copy link
Author

algoroq commented Jan 9, 2025

Thank you

%d is used in Swift because it is shorter - but you can use %lld instead in most cases. So replacing %d with %lld in all text is the best solution? It is just a bit longer.

@JanCizmar
Copy link
Contributor

Hey!

So replacing %d with %lld in all text is the best solution? It is just a bit longer.

Yes, I would recommend this. Even if we stored the information about source Apple placeholder, it might cause other issues like problems with updates to the placeholders and inconsistencies.

So sticking to one specific placeholder is the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants