Comments (9)
if it works in intl-messageformat
there should be no reason it does not work here...as we basically just wrap that module for messageformat format calls
from i18next-icu.
I guess I can't find anything about displaying the currency iso-code in the intl-messageformat docs. I was following the docs from here:
https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#unit-width
Do you know if there's a way displaying the currency iso-code using intl-messageformat?
from i18next-icu.
Personally I only use i18next it's own format...so this really is nothing more than a wrapper for people prefer using message format based on that module of formatjs
from i18next-icu.
Ok, thank you for clarifying.
from i18next-icu.
After a lot of debugging, I found what I believe is a bug.
Lines 660 to 670 in cabd4c0
case 'unit-width-short':
result.currencyDisplay = 'code';
result.unitDisplay = 'short';
continue;
case 'unit-width-iso-code':
result.currencyDisplay = 'symbol';
continue;
It looks like the settings for these two options are swapped. According to mdn web docs, unit-width-iso-code should display a three letter ISO-code, which currently the option "unit-width-short" does, but "unit-width-iso-code" does not.
From my understanding "unit-width-short" should use the symbol option and "unit-width-iso-code" should use "code".
If i use the IntlMessageFormat with code for currencyDisplay, the output result shows the ISO code of currency. So the i18next-icu wrapper seems wrong in this instance.
Example expected behaviour for unit-width-iso-code:
new IntlMessageFormat('The price is: {price, number, USD}', undefined, {
number: {
USD: {
style: 'currency',
currency: 'USD',
currencyDisplay: 'code',
}
}
}).format({price: 100})
Output: The price is: USD 100.00
Example, expected behaviour for unit-width-short:
new IntlMessageFormat('The price is: {price, number, USD}', undefined, {
number: {
USD: {
style: 'currency',
currency: 'USD',
currencyDisplay: 'symbol',
}
}
}).format({price: 100})
Output: The price is: US$100.00
from i18next-icu.
As your wrote before that you're using intl-messageformat": "^10.3.3
it must be an issue there - as our code does not really contain that code you pasted -> that is just bundled from intl-messageformat
But you're directly using latest 10.3.3 of that module - so the issue must still be included there.
from i18next-icu.
To clarify, when i used "new IntlMessageFormat", it was to show that it works when i use new IntlMessageFormat directly, but when i try to translate with icu it doesnt work, and that's because of the rules in the switch case i linked to that are from the file: i18next-icu/i18nextICU.js
But this issue seems to be related to the package "icu-skeleton-parser". There has been issues raised for this in the formatjs repo:
formatjs/formatjs#4038 (comment)
from i18next-icu.
what I said ... is if you're using i18next-icu in not "stone-age" way of require js -> which I assume as you pasted your package.json versions....you don't use i18nextICU.js at all -> you use the npm package es version in the dist folder and whatever version of intl-messageformat, which itself uses that icu-skeleton-parser
in case you really rely on that i18nextICU.js (which looks odd to me) I just updated local intl-messageformat to 10.3.3 and published [email protected] (hope that solves your issue)
from i18next-icu.
You are right in that I'm using the es version, by importing the i18next-icu and bundling through webpack. I highlighted the code in that file to highlight where i noticed the issue with the code, and as you said, the issue probably resides in the icu-skeleton-parser. I tried updating but still the same issue. I can use unit-width-short for now to resolve my issues locally, and update these to the right styles when icu-skeleton-parser fixes the issue.
So the issue is not in this plugin, but since you include it, it's good to know so that when they resolve the issue, you also update that dependency, if this is automated i don't know. But the issue in this repo can be closed since we narrowed it down to icu-skeleton-parser.
from i18next-icu.
Related Issues (20)
- Define an actual interface for IntLocaleData HOT 1
- Currency Message Format not working. HOT 4
- ICU will ignore the first blank in plural HOT 2
- intl-messageformat is egregiously out of date HOT 2
- i18next-icu incompatible with react-i18next <Trans> HOT 4
- Map i18next language code to ICU locale HOT 6
- Upgrading to 2.0.2 - Failed to Compile - Module not found HOT 2
- local-data folder NOT in i18next-icu 2.0.3 HOT 5
- addLocaleData functionality is removed in 2.0 and no migration docs are provided HOT 3
- i18next used in index.d.ts but missing in dependency HOT 2
- ICU pluralisation in Android React Native app breaks if label has # HOT 5
- In-built currency formatting not working with ICU HOT 3
- Interpolation not working in ICU format when fetching an endpoint HOT 13
- Enabling ICU breaks interpolation HOT 5
- ReferenceError: module is not defined HOT 2
- Support Rich Text Formatting (`ignoreTag` to false) HOT 2
- Plural and number format combination HOT 2
- ICU Interpolation does not work with React Native production bundle HOT 4
- Fallback strings are not formatted using the target locale. HOT 13
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 i18next-icu.