Skip to content

Incorrect usage of Trans (Macro) #2220

Answered by timofei-iatsenko
whytspace asked this question in Q&A
Discussion options

You must be logged in to vote

All problems you listed are fixed now in v5:

keys would sometimes change if variable names change. That makes it unmaintainable. I have over 20 languages. Small code changes must not invalidate any of those.

It now possible to make explicit labeled placeholder so changes to variables name, which by design should not change the behavior would not change the placeholder name

t`Hello ${{name: getName()}}`
t`Hello ${{name}}` // <-- shortcut

There is a eslint rule which forces this pattern, and i also considered an automatic migration and sunsetting of using identifier name as placeholder. It looks useful from first impression but then reveal problems as you mentioned.

I have over 20 langua…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@whytspace
Comment options

@timofei-iatsenko
Comment options

Answer selected by whytspace
@whytspace
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants