Comments (8)
Yes this is it. Passing t
function as a parameter to other functions is definitely not supported and won't work as expected. If you happen to call your parameter t
in getErrorMap
function, keys would still be extracted in there, but useTranslation
-specific features such as namespaces wouldn't work properly.
After having a closer look at the plugin code, the fact that this specific warning shows is however unintended and quite unlucky. I'm not sure what to do but given the current state of the code, it seems that the initial intent was indeed to not show anything in such cases. Maybe we should stick to it for now although I don't think it's the cleanest thing to do.
By the way this PR should fix the line numbers showing up in warnings.
from babel-plugin-i18next-extract.
Fixed in 0.2.6 🎉 .
So, the useTranslation-specific features aren't a big deal. […] Not sure how possible that even is though.
I can see at least two major reasons why it's very unlikely we'll ever be able to handle such cases using static analysis:
- When passing
t
as a parameter to a function, all the context you had in it is lost. You may call the same function with another instance oft
somewhere else and therefore keeping track of which namespace is bound to which instance of thet
function would become a nightmare. - As far as I know, Babel just parses one file after another and doesn't create links between the symbols of files (like an IDE would do). That's why keeping contexts across functions that may be imported from another file would be even harder if not impossible using Babel.
from babel-plugin-i18next-extract.
Hi! I don't think the error is at the line you pointed out. Can you try to find which usage of the t
function generate this error message? It is true that the error message isn't very correct though.
from babel-plugin-i18next-extract.
It definitely is that line. Here is an exact error for a specific file:
babel-plugin-i18next-extract: Extraction error in
src/features/Admin/pages/UserProfile/ProfileForm.tsx at line 104.
Couldn't evaluate i18next key. You should either make the key evaluable
or skip the line using a skip comment (/* i18next-extract-disable-line */ or
/* i18next-extract-disable-next-line */).
And the code at that line:
Interestingly, the comment hints also don't work to stop the error.
from babel-plugin-i18next-extract.
What I'm trying to say is that even though the log indicates that the line 104 is at fault, it is probably not the case and it's likely to be a bug somewhere else. It must be one usage of the t
function somewhere after line 104 that generates the warning.
The fact that it indicates the wrong line is another bug I'm working on.
from babel-plugin-i18next-extract.
Ahh, could be that. I do pass the t
function into other functions as an argument. Looks like that is causing it. The error goes away if I put the comment before each of those function calls.
For example, I have stuff like this:
const errorMap = getErrorMap(t);
The error goes away if I do this:
/* i18next-extract-disable-next-line */
const errorMap = getErrorMap(t);
from babel-plugin-i18next-extract.
Yeah, the extracting from the other functions is working properly. I am using the comment hints to set the namespace for each file. So, the useTranslation
-specific features aren't a big deal. They would be a nice thing to have. Not sure how possible that even is though.
from babel-plugin-i18next-extract.
That makes sense. It's no big deal. I can work around it.
Thanks for 0.2.6. It's working great!
from babel-plugin-i18next-extract.
Related Issues (20)
- Support i18next JSON v4's format HOT 5
- Translations not extracted when `t` is used as a template tag literal
- when running tests, I get a warning
- Align Trans key extraction with react-i18next for elements with i18nIsDynamicList
- Ability to extract plurals from defaultValues HOT 1
- Using discardOldKeys keeps only strings from last file
- Allow specifying fallback-functions to parse AST-node for extractors
- Allow defining defaults in the "i18next-extract-mark-context-next-line" directive HOT 1
- extraction not working for TransComponent HOT 5
- Feature key prefixes
- excludes doesn't seem to work HOT 1
- One project where "nested
- Race condition in extract HOT 4
- Can't get an Array of strings to translate HOT 1
- Support fallback keys
- Add comment hint to explicitly register translation keys
- Adding count to t options throws error at computeDerivedKeys and causes webpack build to fail HOT 1
- [BUG][0.9.1] Latest Release Packaging is broken? HOT 2
- translation resource files get overwritten HOT 1
- Docs at netlify appears to be down/not running HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-i18next-extract.