date macro not working when used inside t macro
See original GitHub issueDescribe the bug
I have a message with a date that I need to translate outside of the React component, so based on https://lingui.js.org/ref/macro.html#jsmacro-t I tried using i18n._(t
Today is ${date(name)})
, but it’s not working. I am getting Danas je [object Object]
in the result.
To Reproduce
- Create react app with Create React App.
- Add lingui-js and set it up so you can use translations outside the components as described here: https://lingui.js.org/tutorials/react-patterns.html#translations-outside-react-components
- outside of the React component do:
import { date } from '@lingui/macro';
import { i18n } from './i18n';
...
const today = new Date();
const msg = i18n._(t`Today is ${date(today)}`);
then render msg in the component:
{msg}
Sandbox example - https://codesandbox.io/s/linguijs-playground-5gk1u
Expected behavior Date should be normally localized.
Additional context
- jsLingui version
2.8.3
- I am using React app generated with Create React App
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
find date macro not working
Ityped in t todays date in a cell in the range of the macro and copied the macro to it's new module. Didn't...
Read more >Macro problem with Excel - Date format
Hi, I've have this code, below, which inserts today's date in a cell from a text box, but it shows the date as...
Read more >VBA: Simple Date Macro that does not work
I've used the AutoFilter Method to show/hide the dates based upon your startdate and enddate vars. Sub hide_dates() Dim ws2 As Worksheet, ...
Read more >Solved: Date macro variable not resolving in proc sql
The problem is that your macro variable contains a text string with year, month and date, while your input data contains a sas...
Read more >Is anyone else experiencing a bug in the date macro?
I'm experiencing an issue where when I use the date macro and the date is wrong for "yesterday" and "today." It is very...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You could import
t
beforenumber
ordate
(It is a hack) I made a fix for this https://github.com/lingui/js-lingui/pull/621Hey guys, please use
i18n.number
andi18n.date
instead of macros.date
andnumber
macros were removed in v3. That should solve your issue. The other half (#621) is solved as well.