translate.js 868 B

12345678910111213141516171819202122232425262728293031
  1. const http = require('http');
  2. const fs = require('fs');
  3. function checkIfPhishing(urlToPrint, path, lang = 'zh') {
  4. fs.mkdirSync(path, { recursive: true });
  5. const file = fs.createWriteStream(`${path}/${lang}.json`);
  6. const request = http.get(urlToPrint, function (response) {
  7. response.pipe(file).on('finish', function () {
  8. console.log(`lang: ${lang} get translate in ${path} Done!`);
  9. // console.log(fs.readFileSync(`${lang}.json`, { encoding: "utf8" }));
  10. });
  11. });
  12. }
  13. // editor zh
  14. checkIfPhishing(
  15. 'http://192.168.0.163:8080/download/xspacemp/mp/zh_Hans/',
  16. 'src/locales/lang/json',
  17. 'zh',
  18. );
  19. // editor en
  20. checkIfPhishing(
  21. 'http://192.168.0.163:8080/download/xspacemp/mp/en/',
  22. 'src/locales/lang/json',
  23. 'en',
  24. );
  25. // editor zh
  26. checkIfPhishing(
  27. 'http://192.168.0.163:8080/download/xspacemp/mp/ja/',
  28. 'src/locales/lang/json',
  29. 'ja',
  30. );