Unvalid JSON export
Hello, I'm trying to export a .po file to a .json file but it doesn't seem to be a valid one. Indeed, a path is added at the top of the json file.
The command i'm using : npx ttag po2json i18n/uk.po > i18n/uk.po.json
Here is my uk.po file :
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals = 3; plural = (n % 10 == 1 && n % 100 != 11 ? 0 : n "
"% 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\n"
"Language: uk\n"
"mime-version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: src\App.js:6
msgid "Learn React"
msgstr "Вивчити React"
here is my uk.po.json file :
C:\Users\castagliol\dev\ttag-app\node_modules\ttag-cli\bin\ttag
{"charset":"utf-8","headers":{"content-type":"text/plain; charset=utf-8","plural-forms":"nplurals = 3; plural = (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);","language":"uk","mime-version":"1.0","content-transfer-encoding":"8bit"},"translations":{"":{"":{"msgid":"","msgstr":["Content-Type: text/plain; charset=utf-8\nPlural-Forms: nplurals = 3; plural = (n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);\nLanguage: uk\nmime-version: 1.0\nContent-Transfer-Encoding: 8bit\n"]},"Learn React":{"msgid":"Learn React","msgstr":["ðÆð©ð▓Ðçð©Ðéð© React"]}}}}
Tested on Windows, [email protected]
Hi @adrien-castagliola-cbp! Thanks for the report! Seems like that this shortcut is valid for Unix based systems like Linux or MacOS. I agree that we should have separate specific instructions for the Windows. I'm not quite fluent at windows batch syntax, will try to investigate that issue. Any help will be appreciated also.
Tried to reproduce that case on the Windows 7. And received a valid json. Which version of nodejs and Windows do you use?
Hello,
Thanks for answering me,
Node: v8.11.3 Windows: v10.0.16299
Le lun. 29 avr. 2019 à 11:41, Alexander [email protected] a écrit :
Tried to reproduce that case on the Windows 7. And received a valid json. Which version of nodejs and Windows do you use?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ttag-org/ttag-cli/issues/71#issuecomment-487517978, or mute the thread https://github.com/notifications/unsubscribe-auth/ALXILXSPIPHHDAK52MCIKYLPS27GHANCNFSM4HJBJ6AA .
--
La diffusion de ce message s'effectuant sur un réseau non protégé, nous déclinons toute responsabilité en cas d'altération ou de falsification. As this message is sent through a non protected network, we decline any responsibility should it be altered or falsified
Hi @AlexMost,
I am also facing the same issue. I got this in the po.json file.
yarn run v1.16.0 $ /home/daffodil/react/firelab_superadmin_web/node_modules/.bin/ttag po2json i18n/en.po {"charset":"utf-8","headers":{"content-type":"text/plain; charset=utf-8","plural-forms":"nplurals = 2; plural = (n != 1);","language":"en","mime-version":"1.0","content-transfer-encoding":"8bit"},"translations":{"":{"":{"msgid":"","msgstr":["Content-Type: text/plain; charset=utf-8\nPlural-Forms: nplurals = 2; plural = (n != 1);\nLanguage: en\nmime-version: 1.0\nContent-Transfer-Encoding: 8bit\n"]}}}}Done in 0.51s.
please resolve this asap.
TL;DR
yarn run --silent ... och samma på npx
Long read
yarn adding some output (the other possibility is stdout/stderr mixup).
This is what I use:
for PO in int/*.po;
yarn run --silent ttag po2json --pretty $PO > tmp.json
mv tmp.json (string replace int/ src/int/ (string replace .po .json $PO))
end
-
yarn run --silentsuppresses the script path andDone in Xsoutputs -
... > tmp.json; mv tmp.json final.jsonso that incremental build works(*) -
--prettyfor smaller/saner diffs if JSON is checked in
(*) shell redirect truncates the file first, then ttag runs and eventually fills the file with output, if the file is a build dependency, tools like yarn start will attempt to use the file while it's still empty.
IMO the correct way to "solve" this is to add -o output_file argument to the command, which would do the right thing (save output to temp file, if there's no error, replace the target).
For example yarn pseudo has such option.