Comments (5)
will be fixed by #1850
from js-lingui.
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 String#replace
method. By interpolating first, there is no easy way of knowing where the #
originated from in the component hierarchy. Furthermore, by using the String#replace
method, only the first occurence is replaced as the provided # pattern here is a string. Currently, there is no escape hatch for the replacement of the # symbol that I know of.
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.: There are ${count} apples
). replaceOctothorpe
additionally formats the number for you (number style
by default), but you may do that as you would anywhere else: There are ${i18n.number(count, ...)} apples
. This approach covers more (albeit edge-case) use-case as it allows you to include the number any times, and eliminates the issues related to a bespoke templating systems that sort of goes against the philosophy of the library.
I would love to hear your feedback and please let me know if I missed anything.
from js-lingui.
Thanks for digging into the issue, the "octothorpe" symbol is part of ICU messages spec, so that's why there are here.
from js-lingui.
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 '#'
and a single quote is represented by two consecutive ones ''
. It is described here. You can check out this online editor.
from js-lingui.
Thanks for fixing this! I'm looking forward to the release which will include the fix :)
from js-lingui.
Related Issues (20)
- Update @lingui/vite-plugin to support Vite 5 HOT 10
- Usage with vue & vite with vite plugin HOT 1
- Broken build on CI HOT 6
- Double Render caused by wrong assertion HOT 1
- [Vite] Parentheses in catalog pathnames causes them to be unrecognized HOT 1
- Double render due to wrong assertion on nextjs-babel example HOT 1
- Webpack warning lingui-loader with pnpm HOT 2
- Examples show useEffect deps warning HOT 1
- Cannot kill git pre-commit hook while lingui command is running HOT 4
- Provide some way to turn off newline collapsing HOT 2
- `unraw` default export resolution error in React Native 0.73.2 HOT 1
- Dynamic loading not working with Expo HOT 1
- Support check the translated `msgstr` as expected HOT 2
- Lingui doesn't extract msg within a msg HOT 2
- lingui extract-experimental empty space after {} HOT 2
- Error when aliasing Trans from '@lingui/react' in presence of macro Trans from '@lingui/macro' HOT 2
- `Nextjs` `swc` plugin example not working HOT 3
- Macro: t inside t causing ReferenceError: t is not defined HOT 3
- why not working plural macro? please help me...
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.