| 34 | } |
| 35 | |
| 36 | async rewriteSourceLangFile() { |
| 37 | for (const [key, value] of this.keysMap) { |
| 38 | if (!value) { |
| 39 | delete this.sourceLangMap[key]; |
| 40 | } |
| 41 | } |
| 42 | console.log("Rewrite file:", path.join(LANGUAGE_DIR, LANGUAGE_SOURCE_FILE_NAME)); |
| 43 | fs.writeFileSync( |
| 44 | path.join(LANGUAGE_DIR, LANGUAGE_SOURCE_FILE_NAME), |
| 45 | JSON.stringify(this.sourceLangMap, null, 2) |
| 46 | ); |
| 47 | for (const filename of await fs.promises.readdir(this.languageDir)) { |
| 48 | if (filename.endsWith(".json")) { |
| 49 | const otherLangMap = JSON.parse( |
| 50 | fs.readFileSync(path.join(this.languageDir, filename), "utf-8") |
| 51 | ); |
| 52 | for (const key in otherLangMap) { |
| 53 | if (!this.sourceLangMap[key]) { |
| 54 | delete otherLangMap[key]; |
| 55 | } |
| 56 | } |
| 57 | console.log("Rewrite other lang file:", path.join(this.languageDir, filename)); |
| 58 | fs.writeFileSync( |
| 59 | path.join(this.languageDir, filename), |
| 60 | JSON.stringify(otherLangMap, null, 2) |
| 61 | ); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /** |