i18next / i18next-icu

i18nFormat plugin to use ICU format with i18next
MIT License
81 stars 17 forks source link

date formatting with ICU #14

Closed SCastaneda closed 4 years ago

SCastaneda commented 4 years ago

Hi, I've started using i18next with ICU and it works great with plurals. So first of thanks for this library!

One problem I encountered is that when I try to use date formatting via {x, date, short}, I currently only get some formatting into what mostly looks like ISO, but in some cases like Latvian for example, I'm getting result "2022 M11 14", when really what was expected is "14.11.2022".

The project is using node 8.10.0, Typescript (and yarn 1.21.1). (Pushing to update node version is not possible)

I see that when you don't use ICU, you have formatting options as part of init via interpolation, but the syntax is completely different from ICU, using double {{}} and providing the format itself. Is there something similar we could use for ICU?

What I need is the user friendly short version for each translation, as mentioned above 👆. Best case would be if translators would not have to provide formatting of date.

Thanks!

jamuhl commented 4 years ago

We just use the module done by formatjs - https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat

so we just use that ICU parser from there - nothing more - I can't give you any details on how to use it for your formatting request (as I never used it myself - just gave the option to use ICU messageformat with i18next - personally I will only maintain i18next's main format)...

dyniper commented 4 years ago

I could send you how I customize my dates work this library and ICU if you can wait a couple days. I'm currently away from that code.

On Mon, Feb 17, 2020, 02:56 Jan Mühlemann notifications@github.com wrote:

We just use the module done by formatjs - https://github.com/formatjs/formatjs/tree/master/packages/intl-messageformat

so we just use that ICU parser from there - nothing more - I can't give you any details on how to use it for your formatting request (as I never used it myself - just gave the option to use ICU messageformat with i18next

  • personally I will only maintain i18next's main format)...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/i18next/i18next-icu/issues/14?email_source=notifications&email_token=AAGV22RJ445AINQ5HKMAKALRDJUM7A5CNFSM4KWOYMKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL563AI#issuecomment-586935681, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGV22UX5LAF2ZF45TAOC2LRDJUM7ANCNFSM4KWOYMKA .

SCastaneda commented 4 years ago

I figured out that the issue is that our project isn't using full-icu: https://github.com/nodejs/node/issues/3460

Looks like you have to install full-icu, which provides you with some binary that you have to reference either with an ENV variable NODE_ICU_DATA or via --icu-data-dir flag.

Looks like they made it a default as part of 13.8: https://github.com/nodejs/node/commit/1a25e901b7c380929f0d08599f49dd77897a627f

SCastaneda commented 4 years ago

I'll close this, as it isn't really your issue.