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

feat: allow calls to plural function in no-expression-in-message #48

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

tstehr
Copy link
Contributor

@tstehr tstehr commented Oct 10, 2024

Lingui allows to embed the plural macro inside the t macro, creating a message that includes the plural, similar to nested plurals.

For an example consider the following macro call:

import { plural, t } from '@lingui/macro';
const message = t`Count: ${plural(count, {
  one: '# book',
  other: '# books',
})}`;

It gets represented in the message catalog as a single message: Count: {count, plural, one {# book} other {# books}}.

However the no-expression-in-message rule currently forbids this pattern since the expression in the template string is not an identifier. This PR changes that behavior, allowing calls to the plural function to occur inside the t macro.

Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstehr thank you and congrats on your first contribution! 🎉

@timofei-iatsenko
Copy link
Collaborator

Thanks for contribution, it also should be expanded for other macros, such as select and selectOrdinal

@andrii-bodnar
Copy link
Contributor

@tstehr would you like to add the select and selectOrdinal support within the current PR?

@andrii-bodnar andrii-bodnar merged commit 7a8d062 into lingui:main Oct 11, 2024
2 checks passed
@tstehr tstehr deleted the allow-plural-calls branch October 11, 2024 12:13
@tstehr
Copy link
Contributor Author

tstehr commented Oct 11, 2024

@tstehr would you like to add the select and selectOrdinal support within the current PR?

I've opened up #54 to do that

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

Successfully merging this pull request may close these issues.

3 participants