Closed ttnbtfy closed 10 months ago
Hi @ttnbtfy
Unfortunately, it is not supported yet. Also because of the translating into multiple language in the same time feature, we did not add it. I am adding it to feature list. Thank you.
Hey @ParvinEyvazov I am here because also I want that feature and I can help to achive it.
For example, in my case, I am using a JSON file called: resume.en.json
. I need two different languages: es
& de
. So my CLI script is: jsontt resume.en.json --translator google --from en --to de es
.
What it is name of the file? The main problem is the file name.
If you want to keep the same name:
For example: file.json
=> file.en.json
.
If you want to change the name:
For example: file.json
=> newFile.en.json
What do you think?
Hey @ttnbtfy. Also if you want to change the name, you can create a script for do this task, I have created mine, here it is:
import { writeFileSync, readFileSync, existsSync, unlinkSync } from "fs";
(function rename() {
const files = ["de.json", "es.json"];
try {
files.map((file) => {
if (!existsSync(file)) {
console.log(`File ${file} does not exist`);
return;
}
writeFileSync(`resume.${file}`, readFileSync(file));
unlinkSync(file);
});
} catch (err) {
console.info("err", err);
}
})();
Thank @javix64 for your suggest, can i use this with CLI usage? I don't really understand how to work with Packages
Hi @javix64
Actually, I got an idea from your comment. Maybe what we can do is take a name from the user in the CLI (will be optional) and use it as a prefix
for example in your case:
jsontt resume.en.json --translator google --from en --to de es --name banana
will create a new files wit
banana.de.json
banana.es.json
what do you think guys? Would this also solve your problem @ttnbtfy ?
Yes. In this moment it is the best solution. May I do the changes and after PR? and collaborate in somehow :smiley:
I will definitely try it, I can't test the code right now. Once again thank you very much for those suggestions :)
Sure @javix64, give it a shot!
hey @ttnbtfy I think now you can update to the latest version because I have added the implementation. 😄 and also someone can close this issue!
@javix64 @ttnbtfy Unfortunately not yet.
Noticed an issue while testing. I will fix it soon and will inform you guys when the new release will be published.
perfect :)
Still waiting until there is a new version release so it can be used with CLI command
Hi guys, new version of jsontt now support output name feature. (Thanks to @javix64 )
you can use --name
jsontt <your/path/to/file.json> --translator google --from en --to ar fr zh-CN --name myFiles
Hi, I want to give a different name to the output files, for example below, is this possible?
jsontt your/path/to/file.json --translator google --from en --to fr-my-custom-name.json