Comments (4)
Kinda hacky, but should work:
const count = 0;
const myPluralMessageDescriptor = msg`${plural(count, { one: "Delete # book", other: "Delete # books"})}`
const App = () => {
const { _ } = useLingui();
return _({ ...myPluralMessageDescriptor, values: { count: 1 } })
}
from js-lingui.
Thank you very much for your fast reply, yes, that actually works. Thanks for telling me.
Does this mean that under the hood when extracting the translations via macros the plural function gets replaced first and then the msg can use this? Or how does this work?
from js-lingui.
The macro's code encounters msg
expression and start expanding it recursively. It works the same way how t
macro works.
const translation = t`Are you sure you want to delete ${plural(count, { one: "# book", other: "# books"})}`
The only difference between t
and msg
is the latest is not wrapped in i18n.t
call, and left descriptor as is:
// t
i18n.t({id: "", message: "...."})
// msg / defineMessage
{id: "", message: "...."}
from js-lingui.
Thank your very much for your help and detailed explanation, makes sense. I think we can close this then from my side, there is no separate macro needed.
from js-lingui.
Related Issues (20)
- Extract removes manual comments from po files HOT 1
- React Fragment (`<>`) inside `<Plural>` is not working HOT 5
- Impossible to use with Vite? HOT 1
- rspack now supports wasm plugins, lingui integration example could be improved HOT 3
- Escaped curly-braces doesn't preserve in development mode HOT 1
- <Trans> breaks React JSX semantics with regards to booleans HOT 3
- Consider renaming of the macro components HOT 3
- selectOrdinal error HOT 2
- Lingui CLI extraction puts msgid as msgstr HOT 3
- i18n._(id) throws error if id param passed as undefined
- # is being replaced by%__lingui_octothorpe__% outside plural and selectordinal HOT 3
- Setup with webpack
- Order by is not alphabetically HOT 1
- t`` macro doesn't work when load and activate message HOT 2
- Avoid flashing of the default language HOT 1
- Available~ Free v-bucks Codes in Fortnite- Free v bucks code generator 2024 June Method
- [June-Code]** Free v bucks code generator 2024-2025 Available Free Vbucks Codes in Fortnite
- {Working}++Redeem v bucks codes Available Free v bucks Code 2024
- [Code-Works!]^ Free v bucks code generator 2024 -Are There Any Available Free Vbucks Codes in Fortnite?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-lingui.