-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about removing DateFormat and NumberFormat in v3 #627
Comments
Hey @pavelkuznetsov, those components really haven't done anything else than wrapped |
@tricoder42, thanks for quick reply! I just thought that But, if I understand correctly, react components ( |
Yeah, you need to pull function App() {
const { i18n } = useLingui()
return (
<React.Fragment>
<button
style={{ marginRight: "30px" }}
onClick={() => {
const newLocale = i18n.locale === "en" ? "de" : "en";
i18n.activate(newLocale);
}}
>
Change locale
</button>
{i18n.date(date)}
</React.Fragment>
)
} btw. I assume you use Lingui v3 (from You're right that |
Is there any equivalent now to these version 2 syntaxes? I couldn’t find either in the docs or by trying plausible syntaxes. <NumberFormat
value={value}
format={{ maximumFractionDigits: 0 }}
/>
<DateFormat
value={value}
format={{
year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric',
}}
/> |
@BertrandBordage i am looking for something similar to this as well, the document of Lingui only handles the simpler case : |
Found this @BertrandBordage #299 |
@talhatahir Thanks for sharing! Intl.NumberFormat(
i18n.locale, { maximumFractionDigits: 0 },
).format(value) |
Why? You can perfectly use number() macro, or date() macro. |
@semoal Thanks for insisting on it, I now see that we can use: i18n.number(value, { maximumFractionDigits: 0 }) I was initially trying to use |
Yes, we have tons of pending work inside documentation because v3 has been an amazing rework internally of how Lingui works. Tomas and me pushed hard to release the v3, but documentation it's a bit "old". The codemod is really helpful and probably will migrate 90/95% of the codebase to lingui v3 best practices. So if you have any doubt the codemod will resolve your question |
Hello. Thanks for excellent work with lingui!
I am using
NumberFormat
andDateFormat
from@lingui/react
in my project a lot. Today i couldnt find them in the docs, but in sectionMigration guide from 2.x to 3.x
i found -->NumberFormat and DateFormat components were removed. Use date and number formats from @lingui/core package instead.
I'm just wondering is there any specific reason for it? Will it be safe to implement similar wrappers by myself in v3 or are there any concerns about it? (I see that
withI18n
high-order component was removed as well, but it looks likeuseLingui
can be used instead).The text was updated successfully, but these errors were encountered: