question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plural component requires extract string on each update

See original GitHub issue

Describe the bug In development, when I update strings inside a <Plural> I have to run extract-strings to render those updated strings properly. I do not have to do that for strings marked for translation inside i18n.(). Is this expected.

To Reproduce Create <Plural count={jobs} one= "job" other="jobs"/>

replacing the Plural component with the raw I18n function also does not render the proper string until I extract the the strings.
i18n._( '{numItemsToDelete, plural, one {The inventory will be in a pending status until the final delete is processed.} other {The inventories will be in a pending status until the final delete is processed.}}', { numItemsToDelete: selected.length } )

refresh the screen. Expected behavior Expect that when count is 1 string = job and when count is >1 string = jobs Additional context Something like “{0, plural, one {You do not have permission to cancel the following job:} other {You do not have permission to cancel the following jobs:}}” is rendered. Notice both strings are rendered inside of the {}

My concern here is that if I extract the strings each time they change in order to get them to render properly while in dev. mode I will have a lot of noise in my PRs with these changes, and also that when I ship the compiled strings out to the translation contractors, that actually do the translations, there will be all sorts of merge conflicts when they come back.

  • jsLingui version 3.7.1
  • Babel version 7.0.0
  • Create React App

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
semoalcommented, May 11, 2021

I fixed it guys, the issue was Lingui needs a development runtime for development purposes and another for production, i forgot to add that development entrypoint when i’ve moved the ESM responsability to Rollup, my bad.

I’ve tried it with the CRA that we have in our examples and it’s fixed so probably will be fixed also for you 😃

I plan to release this the next tuesday, since I want to try to fix some extra bugs 😃 Hope this is not an issue for you

1reaction
semoalcommented, May 11, 2021

@semoal thanks for offering your help, its greatly appreciated!

I was able to track down the breaking change to have happened between 3.5.1 (working as expected) and 3.6.0 (displaying ICU strings). Please let me know if I can be of assistance in any other way.

Looks related to the ESM bundling, probably something is not exported correctly. I’ll try to take a closer look tonight!

Thanks for your work mate

Read more comments on GitHub >

github_iconTop Results From Across the Web

R substr & substring Functions | Examples: Remove, Replace ...
How to apply substr & substring in R - 5 actionable examples - Extract, remove, replace, or find matches in a character string...
Read more >
Manipulating String Data in R - Pluralsight
This is helpful in cases like date and time stored together as a string and you need to extract only the date part...
Read more >
String resources | Android Developers
A plural or singular string. The value can be a reference to another string resource. Must be a child of a <plurals> element....
Read more >
The String Component (Symfony Docs)
In some scenarios such as code generation and code introspection, you need to convert words from/to singular/plural. For example, to know the property ......
Read more >
@lingui/macro - Reference — LinguiJS documentation
JSX macros are transformed to <Trans> component from @lingui/react: ... If you need to add variables to plural form, you can use template...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found