-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
140 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import path from 'path'; | ||
import cp from 'child_process'; | ||
|
||
export const PROJECT_ROOT = path.join(import.meta.dirname, '..'); | ||
|
||
export const executeCommand = (command, args, cwd) => { | ||
const result = cp.spawnSync(command, args, { stdio: 'inherit', cwd }); | ||
if (result.error) { | ||
throw result.error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env node | ||
|
||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import { PROJECT_ROOT } from '../utils.js'; | ||
|
||
const deepMerge = (target, source) => { | ||
for (const key of Object.keys(source)) { | ||
if (typeof source[key] === 'object' && target[key]) { | ||
deepMerge(target[key], source[key]); | ||
} else { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return target; | ||
}; | ||
|
||
const main = () => { | ||
const oputBuildPath = path.join(PROJECT_ROOT, 'lib/vscode/out-build'); | ||
const nlsKeys = JSON.parse(fs.readFileSync(path.join(oputBuildPath, 'nls.keys.json'))); | ||
const nlsMessages = JSON.parse(fs.readFileSync(path.join(oputBuildPath, 'nls.messages.json'))); | ||
|
||
const languageContentsMap = {}; | ||
const i18nPath = path.join(PROJECT_ROOT, 'lib/vscode-loc/i18n'); | ||
|
||
for (const languageDir of fs.readdirSync(i18nPath)) { | ||
const languagePath = path.join(i18nPath, languageDir); | ||
const packageJson = JSON.parse(fs.readFileSync(path.join(languagePath, 'package.json'))); | ||
|
||
for (const localization of packageJson.contributes.localizations) { | ||
if (!languageContentsMap[localization.languageId]) { | ||
languageContentsMap[localization.languageId] = {}; | ||
} | ||
|
||
const contents = languageContentsMap[localization.languageId]; | ||
for (const translation of localization.translations) { | ||
const translationPath = path.join(languagePath, translation.path); | ||
deepMerge(contents, JSON.parse(fs.readFileSync(translationPath)).contents); | ||
} | ||
} | ||
} | ||
|
||
for (const languageId of Object.keys(languageContentsMap)) { | ||
const langMessages = []; | ||
const contents = languageContentsMap[languageId]; | ||
|
||
for (const [file, keys] of nlsKeys) { | ||
for (const key of keys) { | ||
langMessages.push(contents[file][key] || nlsMessages[langMessages.length]); | ||
} | ||
} | ||
if (langMessages.length !== nlsMessages.length) { | ||
throw new Error(`Invalid nls messages for ${languageId}`); | ||
} | ||
|
||
const nslDirPath = path.join(PROJECT_ROOT, `dist/nls/${languageId}`); | ||
fs.ensureDirSync(nslDirPath); | ||
fs.writeFileSync( | ||
path.join(nslDirPath, 'nls.messages.js'), | ||
`globalThis._VSCODE_NLS_MESSAGES=${JSON.stringify(langMessages)};` + | ||
`globalThis._VSCODE_NLS_LANGUAGE=${JSON.stringify(languageId)};`, | ||
); | ||
} | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#!/usr/bin/env node | ||
|
||
import path from 'path'; | ||
import cp from 'child_process'; | ||
import { PROJECT_ROOT } from '../utils.js'; | ||
import { executeCommand, PROJECT_ROOT } from '../utils.js'; | ||
|
||
const main = () => { | ||
const cwd = path.join(PROJECT_ROOT, 'lib/vscode'); | ||
cp.spawnSync('npm', ['run', 'gulp', 'vscode-web-min'], { stdio: 'inherit', cwd }); | ||
executeCommand('npm', ['run', 'gulp', 'vscode-web-min'], cwd); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#!/usr/bin/env node | ||
|
||
import path from 'path'; | ||
import cp from 'child_process'; | ||
import { PROJECT_ROOT } from '../utils.js'; | ||
import { executeCommand, PROJECT_ROOT } from '../utils.js'; | ||
|
||
const main = () => { | ||
const cwd = path.join(PROJECT_ROOT, 'lib/vscode'); | ||
cp.spawnSync('npm', ['run', 'watch-web'], { stdio: 'inherit', cwd }); | ||
executeCommand('npm', ['run', 'watch-web'], cwd); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
#!/usr/bin/env node | ||
|
||
import path from 'path'; | ||
import cp from 'child_process'; | ||
import { PROJECT_ROOT } from '../utils.js'; | ||
import { executeCommand, PROJECT_ROOT } from '../utils.js'; | ||
|
||
const main = () => { | ||
const cwd = path.join(PROJECT_ROOT, 'lib/vscode'); | ||
cp.spawnSync('npm', ['run', 'watch'], { stdio: 'inherit', cwd }); | ||
executeCommand('npm', ['run', 'watch'], cwd); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters