Closed manuel-woelker closed 5 years ago
Hi @manuel-woelker, glad that you liked our lib. Seems like it's a bug. Going to investigate, will report any progress here.
Thanks for the quick feedback! Let me know if I can support in any way.
You can try the new version of ttag-cli@1.7.2
that fixes this issue. I have tried on your example repo and yarn run precompile
produces the following:
"use strict";
var _ttag = require("ttag");
// works
console.log("one"); // doesn't work, only outputs "two;"
console.log("two"); // works - wrapped with a bogus function
console.log(make_it_work("two"));
Please, let me know if that works for you.
I just verified with 1.7.2 and it's looking great! Thanks again for the quick fix.
Hi, first of all thanks for the great lib - much appreciated! However I ran into a bit of an issue today:
When using ttag-cli to precompile translations, the resulting code is malformed. I put up a simple demo repo here: https://github.com/manuel-woelker/ttag-precompile-context/blob/master/test.x.js (Run using
yarn install && yarn run precompile
) Input (in file test.js):Expected output (in test.x.js, using translation file x.po):
Actual output:
Interestingly, wrapping the translation part with a bogus function makes it work, e.g.:
My best guess is that the transformation function is somehow removing too much of the AST during the replacement.
It could also reproduce this with the babel-plugin-ttag and babel-plugin-macros.
Any ideas what the issue might be? Thanks in advance!