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

--placeholder-format printf should have option for named-string interpolation #113

Open
damiaanh opened this issue Apr 11, 2023 · 0 comments

Comments

@damiaanh
Copy link

Currently the--placeholder-format option printf is converting universal placeholders to use with positional interpolation. This is not the best for translations, as positions of variables can differ in different languages.

i.e. "Login and follow @[%1$s:name] to see all [%1$s:count] messages" --> "Login and follow @%1$s to see all %1$s messages"

As Django's documentation says:

This technique lets language-specific translations reorder the placeholder text. For example, an English translation may be "Today is November 26.", while a Spanish translation may be "Hoy es 26 de noviembre." – with the month and the day placeholders swapped.

For this reason, you should use named-string interpolation (e.g., %(day)s) instead of positional interpolation (e.g., %s or %d) whenever you have more than a single parameter. If you used positional interpolation, translations wouldn’t be able to reorder placeholder text.

Is it possible to add an placeholder format that respects the name of the universal placeholder?

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

1 participant