Closed iDVB closed 2 years ago
The myArr.map(t)
happens at runtime. It'd be very cumbersome to parse such complex case using a static analyzer. In your example, you'd need to resolve the myArr
reference which'd be even harder than, say, ["thing 1", "thing 2"].map(t)
. Maybe there should be an entry in the FAQ like "Why doesn't it extract keys in my very-specific use-case?" to explain the whys in details.
The recommended way is : const translatedArr = [t('thing 1'), t('thing 2'), t('thing 3')]
or if you need to keep the keys in an array, the plugin should be smart enough to parse this:
const K_THING_1 = 'thing 1';
const K_THING_2 = 'thing 2';
const K_THING_3 = 'thing 3';
const myArr = [K_THING_1, K_THING_2, K_THING_3];
const translatedArr = [t(K_THING_1), t(K_THING_2), t(K_THING_3)];
I don't think it will do more and I don't think it should do more, therefore I'll close this issue as wontfix.
I have a long-term project of adding a plugin API that would allow one to create custom extractors for such specific scenarios. But I'm not sure if and when I'll have the incentives to actually implement that API.
Describe the bug
How to reproduce Trying to get an array in code to translate and extract.
Expected behavior
I would expect that in the translation json file it would have
What actually happens
There is nothing extracted.