-
Notifications
You must be signed in to change notification settings - Fork 375
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
Using Trans inside a Plural macro unexpectedly replaces "#" found in variables #1826
Comments
Hi, I investigated this issue and I believe the core of the issue is that the interpolation here runs before the replaceOctothorpe function that uses the To solve this issue I propose the following: Remove the # related behavior entirely I believe that a better and simpler solution to include the actual number in a plural sentence is to use the well-established templating approach of Lingui (e.g.: I would love to hear your feedback and please let me know if I missed anything. |
Thanks for digging into the issue, the "octothorpe" symbol is part of ICU messages spec, so that's why there are here. |
Thank you for the rapid response. You are correct I did not consider that, so the replacing of the # is correct, except I believe every instance should be replaced. Furthmore, literal # and any other special symbols are supported by enclosing them in single quotes |
will be fixed by #1850 |
Thanks for fixing this! I'm looking forward to the release which will include the fix :) |
Describe the bug
Using
Trans
with thePlural
macro can lead to variables being rendered in a modified way. It should be possible for a variable to contain "#" without it being replaced with thevalue
of thePlural
macro.To Reproduce
Define a component, which uses a nested
Trans
within thePlural
macro:Expected behavior
Rendering the component using this code:
Should result in
but it generates
As you can see, the "#" found in the
documentTitle
variable is replaced with the count "1". It renders asTitle 11
instead ofTitle #1
.I think the expected behavior is to leave variables untouched and render them as is. Only hashtags that are directly part of the translation string should be replaced.
Additional context
4.6.0
7.23.3
babel-macro-plugin
The text was updated successfully, but these errors were encountered: