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

i18n._ function removes unrecognized macros #1278

Closed
nmoinvaz opened this issue Aug 18, 2022 · 3 comments · Fixed by #1328
Closed

i18n._ function removes unrecognized macros #1278

nmoinvaz opened this issue Aug 18, 2022 · 3 comments · Fixed by #1328
Assignees

Comments

@nmoinvaz
Copy link
Contributor

nmoinvaz commented Aug 18, 2022

Describe the bug
i18n._ removes macros that are unrecognized. This prevents programs that also parse macros in strings from handling them after Lingui loads them.

To Reproduce
Using the following code:

i18n._("code {hello}")

The string returned is code .

Expected behavior
It should return code {hello} because no values object was passed to i18n._.

Alternatives ideas

  1. Perhaps there is a callback that can be triggered when it encounters a macro it doesn't recognize?
  2. Or an option that can be enabled for this behavior?
  3. Or another function that does not process macros but can get the locale string.
@nmoinvaz nmoinvaz changed the title i18n._ function removes unavailable macros i18n._ function removes unrecognized macros Aug 18, 2022
@nmoinvaz
Copy link
Contributor Author

nmoinvaz commented Sep 23, 2022

Worse case, it looks like according to PEG, it should be possible using a literal to bypass parsing.

i18n._("code '{hello}'")

Translates to "code {hello}"

@stale
Copy link

stale bot commented Nov 22, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@timofei-iatsenko
Copy link
Collaborator

Fixed, starting from next version

i18n._("code '{hello}'")

Should work

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

Successfully merging a pull request may close this issue.

4 participants