Macro `t` with template string id could not be extracted
See original GitHub issueDescribe the bug
Macro t
will NOT be extracted to message catalog, if we pass id with a template string like t({id: `id`})
.
To Reproduce
import { t } from '@lingui/macro'
export default function App() {
return (
<div>
<p>
{/* id with string */}
{t({
id: 'today1',
message: `Today is ${new Date()}`,
})}
</p>
<p>
{/* id with template literals */}
{t({
id: `today2`,
message: `Today is ${new Date()}`,
})}
</p>
</div>
)
}
Only today1
is extracted, but today2
is missing:
{
"today1": {
"translation": "Today is {0}",
"message": "Today is {0}",
"extractedComments": []
}
}
Expected behavior
today 2
should also be extracted.
Additional context Add any other context about the problem here.
- jsLingui version
3.4.0
- Babel version
@babel/core@7.12.10
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How can I resolve Error: variable template-id 'complex type' in ...
It's a bit unusual to alias a type as value . Instead, I recommend you declare it as a static member so that...
Read more >@lingui/macro - Reference — LinguiJS documentation
This comment tells the extract plugin that following object or string should be collected to message catalog. t¶. t¶. The most common macro...
Read more >Language Reference — Chameleon 3.8 documentation
The Template Attribute Language Expression Syntax (TALES) standard describes expressions that supply Basics (TAL) and Macros (METAL) with data. TALES is one ...
Read more >Template Designer Documentation - Jinja
If a variable or attribute does not exist, you will get back an undefined value ... Jinja to trim_blocks , the first newline...
Read more >Replacing text macros - cppreference.com
The syntax of a function-like macro invocation is similar to the syntax ... If the identifier is not in functional-notation, i.e. does not...
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 FreeTop 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
Top GitHub Comments
Released this feature/fix on 3.8.3 guys! Thanks to everyone and special to thanks to @sultan99 who resolved this issue!
The “common” behaviour is to define id like a simple string with double/single quotes, that’s why the standard implementation works. When Tom refactored the v2 codebase to v3, probably didn’t though about this use case, but is not against the philosophy of Lingui, it’s just okay, (no free time on my side, and still less on Tom side)
Feel free to take it and ping me if you need some guidance =)