-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using it with react_templates #18
Comments
Hi @jenseng, i have a fix for this problem.
In this case @ekaradon should call I create the jenseng/i18nliner-js#18 PR in the Cheers |
@Fraisse Thanks for the PR, I'll check it out! @ekaradon Though even with that PR, I suspect react-i18nliner won't work in its current form with react-templates, since it preprocesses JSX, not HTML (I'm fairly certain both esprima and acorn would choke on .rt, and recast definitely would not generate valid .rt). Also, react-i18nliner uses the same processor for both regular .js files as well as .jsx (since JSX is a superset of JS). So I think we'd probably need a brand new pre-processor for .rt files. That said, you should be able to use i18nliner-js today via javascript expressions, e.g.
Note that you'll want to run the i18nliner |
@jenseng Thanks for the answer, Indeed, it does not work. It is stuck with an error complaining about a malformed string:
But I am not sure about what it would take to make it work and what need to be done. Is it possible to get further explanations about the pre-processing thing? Also, I would like to know what the pre-processing outputs. I first thought that it was transforming the balise from:
to:
But if such was the case, It would works with esprima without complaints. |
Hello, Would it be possible to get some clues about this topic? I am hesitating between using react-intl8 and this project but I would prefer to use this last one because the syntax is nicer. However, I am a bit stuck with this error of compilation and as I have no idea about how long it would take to support react-templates, I am in the dark. |
Hello, |
@ekaradon / @ailonn: sorry for the delayed response, I've had a busy couple weeks... react-i18nliner parses javascript files to find JSX elements with So in its current state, there's not currently any way to use react-i18nliner on an .rtl file. And unfortunately, I don't have any immediate plans to support it. That said, I'd be happy to entertain pull requests that do add support. Though ideally, I think it would make even more sense as a separate NPM module (e.g. react-templates-i18nliner), and I'd be happy to provide some direction on how to go about it. react-templates uses cheerio to parse the HTML in your .rtl file into a tree, and then generates javascript from it. So for react-templates-i18nliner, it seems like you would want to:
The pre-processor would have a lot of parallels to react-i18nliner's, the fundamental difference being it would operate on a cheerio tree instead of an esprima AST. All that said, you should be able to use i18nliner as-is (e.g. {
"directories": ["dist"],
} I hope that helps! |
@jenseng, thanks for your answer. It did help me to see more clearly how it works. Indeed, react-templates was giving me some real headaches using it with different libraries like yours, react-router or even worse was giving me new bugs that pure JSX have not (like ignoring setting disabled). Anyway, the problem is solved for my part and I will be using your library. I let you choose if you want to close this ticket or let it opened for newcomers. Cheers! |
Hello,
I try to use this library in my application and I have a little issue. Indeed, I am using the (https://github.com/wix/react-templates)[react templates library] and it is using the extension .rt and not the .js or the .jsx extension. And I do not find how-to configure .i18nrc in order to change this pattern.
Cheers,
The text was updated successfully, but these errors were encountered: