Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
|
I added test now, I want figure out how to compile code with this to build example, I wish if there are instructions -if it is ok- then, I will add doc later. code should use as: |
There is contribution guide, it has instructions how to compile and use in your host project or example.
I don't see where this method is bound to i18n instance. |
thank you I will review how to bind to i18n instance |
packages/core/src/formats.ts
Outdated
| unit: Intl.RelativeTimeFormatUnit, | ||
| format?: Intl.RelativeTimeFormatOptions | ||
| ): string { | ||
| if ((isDate(value) || isString(value)) && unit) throw new Error('with units you should use numbers as values') |
There was a problem hiding this comment.
I'm not a maintainer, so take this only as a recommendation, but I think the error message can be improved a little. eg. it could contain the value.
I also wonder if it's needed to catch this case; what error is thrown by Intl.RelativeTimeFormat in this case?
There was a problem hiding this comment.
I removed error message, I planned to make relative accept date or string and generate (value, unit) from it, I will ignore that for now.
|
I bind it to |
|
I'm going to raise a few bigger questions here: Do we need relative date formatting in the library? Where I'm going is this: we do need some things - for example, we probably use number formatting when working with plurals (I didn't check, I'm just guessing here). Do we need date formatting? It seems like we don't? Maybe it's just a convenience functionality that was added at some point? But I'd like to warn against adding convenience functions "just because". In my opinion, Lingui should not expose too many functions that are only wrappers over the Intl api if the library itself has no use for them. There are many Intl apis and, by extension, if we were to wrap them all we'd just end up with a bunch of bloat. I think in this case, we should not add this functionality. Thank you :) |
|
@vonovak, I prefer to manage my internationalization code from one place, I need make About date and number, I think formatting provided before by linguijs with their code, the difference they now move to use browser API to manage them, so does we need them? yes, we need them, and I think other libraries provide them. if you think there is better solution, I will be thankful for you to share. |
|
BTW i also think that this could be solved in the userland with a little effort. And it's better not bloat a library with optional extras. Current core architecture made in the way that all this additional methods are not tree-shakeable. So every addition will be added to every bundle where lingui is used. |
No description provided.