Comments (13)
so as change already made we keep current change in hope we did not open a box ;)
from i18next-icu.
The language code in the resources is important.
So, this works:
i18next.use(ICU).init({
debug: true,
lng: "fr",
fallbackLng: "fr-CA",
resources: {
"fr-CA": {
translation: {
short_date: "fr-CA: {date, date, short}"
}
},
"en-CA": {
translation: {
short_date: "en-CA: {date, date, short}"
}
}
}
});
i18next.t("short_date", { date: new Date(2000, 1, 29) }) // fr-CA: 00-02-29
i18next.t("short_date", { date: new Date(2000, 1, 29), lng: 'en-CA' }) // en-CA: 00-02-29
from i18next-icu.
Hello @adrai,
While I know that providing the string in the resources will mitigate the issue, Iโm saying that the normal behaviour of i18next is to format the string with the target locale as a base.
import i18next from 'i18next';
i18next.init({
lng: "fr-CA",
resources: {
en: {
translations: {
date: "{{date, datetime}}"
},
},
},
});
console.log(i18next.t("date", { date: new Date(2000, 1, 29) })); // 2000-02-29 (Which is the fr-CA value using Intl.DateTimeFormat.)
import i18next from 'i18next';
i18next.init({
lng: "fr",
resources: {
en: {
translations: {
date: "{{date, datetime}}"
},
},
},
});
console.log(i18next.t("date", { date: new Date(2000, 1, 29) })); // 29/02/2000 (Which is the fr-FR value using Intl.DateTimeFormat.)
from i18next-icu.
Can you try with i18next v23.4.6 ?
from i18next-icu.
wrong...format inside gets done with the language i18next is able to resolve a resource -> if it resolves the en
string it will format dates in english format and not in french -> to keep a string consistent
from i18next-icu.
Can you try with i18next v23.4.6 ?
It solved the issue, thanks!
from i18next-icu.
23.4.6 is breaking change and wrong -> rollback is needed
from i18next-icu.
23.4.6 is breaking change and wrong -> rollback is needed
While I agree that it is a breaking change, I donโt understand why it is wrong since itโs the default behavior of i18next?
import i18next from 'i18next'; //v23.4.5
i18next.init({
lng: "de-DE",
resources: {
en: {
translations: {
date: "Latest tetracentennial leap day: {{date, datetime}}",
},
},
},
});
console.log(i18next.t("date", { date: new Date(2000, 1, 29) })); // Latest tetracentennial leap day: 29.2.2000
from i18next-icu.
then the default behaviour might be wrong - formatting and language should be consistent...or do you like german strings with american dates?
from i18next-icu.
then the default behaviour might be wrong - formatting and language should be consistent...or do you like german strings with american dates?
Then itโs no use to follow this principle since those format might not be valid.
https://www.i18next.com/principles/fallback#variant-resolving-fallback-from-dialects-or-scripts
from i18next-icu.
in that case we would have to decide on locale for formatting depending if it is a fallback to non regional variant...so you're right...both options are currently wrong depending on the fallback comes from same language or not
from i18next-icu.
in that case we would have to decide on locale for formatting depending if it is a fallback to non regional variant...so you're right...both options are currently wrong depending on the fallback comes from same language or not
As a compromise, I would be happy with that solution.
But in both cases (i18next current behavior and i18next-icu v23.4.5 behavior) it will be a breaking change.
from i18next-icu.
ok, let's close this issue now ;-)
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
- Currency in skeleton with unit-width-iso-code does not work. HOT 9
- Plural and number format combination HOT 2
- ICU Interpolation does not work with React Native production bundle HOT 4
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.