mololab / json-translator

jsontt 💡 - AI JSON Translator + other FREE translation modules to translate your json/yaml files into other languages ✅ Check Readme ✌
https://mololab.org/jsontt/npm
MIT License
427 stars 53 forks source link

Has anyone actually be able to make this work? #48

Open mfalconi-perle opened 6 months ago

mfalconi-perle commented 6 months ago

Does anything other than the CLI actually work for this? Even that is broken and doesnt parse valid html.

ParvinEyvazov commented 6 months ago

Hello @mfalconi-perle,

I am sorry, I didn't get what you mean. Can you please share more detailed information?

mfalconi-perle commented 6 months ago

Hello @mfalconi-perle,

I am sorry, I didn't get what you mean. Can you please share more detailed information?

Error: Command failed: jsontt C:\Users\username\Desktop\websites\site\site\wwwroot\JSON\Applications_Solutions\Broadcasting\bbc.json --module bing --from en --to de --name C:\Users\MichaelFalconi\Desktop\websites\perlesystems.de\perlesystems.de\wwwroot\JSON\Applications_Solutions\Broadcasting\it-helpdesk-use-ethernet-extenders --fallback yes --concurrencylimit 10
undefined:1
{
^

SyntaxError: Unexpected token '', "{
  "Met"... is not valid JSON
const translator = require('@parvineyvazov/json-translator');
let fs = require('fs');
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);

async function genFiles(){
  let path = 'C:\\Users\\username\\Desktop\\websites\\site\\site\\wwwrootJSON\\Applications_Solutions';
  let SubDirs = fs.readdirSync(path);
  for(i = 0; i < SubDirs.length; i++)
  {
    console.log(SubDirs[i]);
    if(SubDirs[i] != "template.json"){
      let files = fs.readdirSync(`${path}/${SubDirs[i]}`);
      for(j = 0;j < files.length; j++)
      {
        let s = `${path}\\${SubDirs[i]}\\${files[j]}`;
        s = s.replace("/", "\\");
        console.log(`translating: ${s}`)        
        let outpath = `C:\\Users\\username\\Desktop\\websites\\perlesystems.de\\perlesystems.de\\wwwroot\\JSON\\Applications_Solutions\\${SubDirs[i]}\\${files[i]}`;
        outpath = outpath.replace(".json", "");
        const { stdout, stderr } = await exec(`jsontt ${s} --module bing --from en --to de --name ${outpath} --fallback yes --concurrencylimit 10`);
        console.log(stdout)
        console.log(stderr)        
      }      
    }
  }
}
genFiles();

Whether i run the above code or use the CLI i get invalid JSON error, or Cannot save file errors. I have validated the json with other tools and know for a fact is valid.