Explorar el Código

feat: 接入翻译平台JSON

gemercheung hace 1 año
padre
commit
d42ebd3525
Se han modificado 5 ficheros con 29 adiciones y 2 borrados
  1. 1 0
      .eslintignore
  2. 1 0
      package.json
  3. 1 1
      src/locales/lang/json/zh_Hans.json
  4. 1 1
      src/locales/lang/zh_CN.ts
  5. 25 0
      translate.js

+ 1 - 0
.eslintignore

@@ -14,3 +14,4 @@ dist
 /bin
 Dockerfile
 deno_convert.ts
+translate.js

+ 1 - 0
package.json

@@ -6,6 +6,7 @@
     "serve": "npm run dev",
     "dev": "vite",
     "build": "cross-env NODE_ENV=production vite build --mode production && esno ./build/script/postBuild.ts",
+    "translate": "node translate.js",
     "build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts",
     "build:no-cache": "pnpm clean:cache && npm run build",
     "report": "cross-env REPORT=true npm run build",

+ 1 - 1
src/locales/lang/json/zh_Hans.json

@@ -583,5 +583,5 @@
     "routes.staff.staffList": "员工列表",
     "routes.staff.roleType.0": "公司管理员",
     "routes.staff.roleType.1": "公司员工",
-    "routes.corporation.test123": "zh-test123"
+    "routes.corporation.test123": "zh-test123 "
 }

+ 1 - 1
src/locales/lang/zh_CN.ts

@@ -2,7 +2,7 @@
 import antdLocale from 'ant-design-vue/es/locale/zh_CN';
 
 // const modules = import.meta.globEager('./zh-CN/**/*.ts');
-import Hans from './json/zh_Hans.json';
+import Hans from './json/zh-CN.json';
 
 export default {
   message: {

+ 25 - 0
translate.js

@@ -0,0 +1,25 @@
+const http = require('http');
+const fs = require('fs');
+
+function checkIfPhishing(urlToPrint, path, lang = 'zh') {
+  fs.mkdirSync(path, { recursive: true });
+  const file = fs.createWriteStream(`${path}/${lang}.json`);
+  const request = http.get(urlToPrint, function (response) {
+    response.pipe(file).on('finish', function () {
+      console.log(`lang: ${lang} get translate in ${path} Done!`);
+      // console.log(fs.readFileSync(`${lang}.json`, { encoding: "utf8" }));
+    });
+  });
+}
+// editor zh
+checkIfPhishing(
+  'http://192.168.0.163:8080/download/geo_jp/backend/zh_Hans/',
+  'src/locales/lang/json',
+  'zh-CN',
+);
+// editor en
+checkIfPhishing(
+  'http://192.168.0.163:8080/download/geo_jp/backend/ja/',
+  'src/locales/lang/json',
+  'ja',
+);