mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-10 00:27:05 -06:00
nls follow up debt work (#219265)
This commit is contained in:
parent
376a7f73ed
commit
d65fd5ba2e
@ -84,6 +84,7 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
|
||||
});
|
||||
|
||||
// Disable mangling for the editor, as it complicates debugging & quite a few users rely on private/protected fields.
|
||||
// Disable NLS task to remove english strings to preserve backwards compatibility when we removed the `vs/nls!` AMD plugin.
|
||||
const compileEditorAMDTask = task.define('compile-editor-amd', compilation.compileTask('out-editor-src', 'out-editor-build', true, { disableMangle: true, preserveEnglish: true }));
|
||||
|
||||
const optimizeEditorAMDTask = task.define('optimize-editor-amd', optimize.optimizeTask(
|
||||
|
||||
@ -52,18 +52,9 @@ const BUILD_TARGETS = [
|
||||
|
||||
const serverResources = [
|
||||
|
||||
// Bootstrap
|
||||
'out-build/bootstrap.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
'out-build/bootstrap-amd.js',
|
||||
'out-build/bootstrap-node.js',
|
||||
|
||||
// NLS
|
||||
'out-build/nls.messages.json',
|
||||
|
||||
// Performance
|
||||
'out-build/vs/base/common/performance.js',
|
||||
|
||||
// Process monitor
|
||||
'out-build/vs/base/node/cpuUsage.sh',
|
||||
'out-build/vs/base/node/ps.sh',
|
||||
@ -427,7 +418,8 @@ function tweakProductForServerWeb(product) {
|
||||
src: 'out-build',
|
||||
entryPoints: [
|
||||
'out-build/server-main.js',
|
||||
'out-build/server-cli.js'
|
||||
'out-build/server-cli.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
],
|
||||
platform: 'node',
|
||||
external: [
|
||||
|
||||
@ -51,18 +51,12 @@ const vscodeEntryPoints = [
|
||||
].flat();
|
||||
|
||||
const vscodeResources = [
|
||||
'out-build/bootstrap.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
'out-build/bootstrap-amd.js',
|
||||
'out-build/bootstrap-node.js',
|
||||
'out-build/bootstrap-window.js',
|
||||
'out-build/nls.messages.json',
|
||||
'out-build/nls.keys.json',
|
||||
'out-build/vs/**/*.{svg,png,html,jpg,mp3}',
|
||||
'!out-build/vs/code/browser/**/*.html',
|
||||
'!out-build/vs/code/**/*-dev.html',
|
||||
'!out-build/vs/editor/standalone/**/*.svg',
|
||||
'out-build/vs/base/common/performance.js',
|
||||
'out-build/vs/base/node/{stdForkStart.js,terminateProcess.sh,cpuUsage.sh,ps.sh}',
|
||||
'out-build/vs/base/browser/ui/codicons/codicon/**',
|
||||
'out-build/vs/base/parts/sandbox/electron-sandbox/preload.js',
|
||||
@ -111,12 +105,14 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
|
||||
src: 'out-build',
|
||||
entryPoints: [
|
||||
'out-build/main.js',
|
||||
'out-build/cli.js'
|
||||
'out-build/cli.js',
|
||||
'out-build/bootstrap-fork.js',
|
||||
],
|
||||
platform: 'node',
|
||||
external: [
|
||||
'electron',
|
||||
'minimist',
|
||||
'original-fs',
|
||||
// TODO: we cannot inline `product.json` because
|
||||
// it is being changed during build time at a later
|
||||
// point in time (such as `checksums`)
|
||||
|
||||
@ -31,6 +31,7 @@ const quality = product.quality;
|
||||
const version = (quality && quality !== 'stable') ? `${packageJson.version}-${quality}` : packageJson.version;
|
||||
|
||||
const vscodeWebResourceIncludes = [
|
||||
|
||||
// Workbench
|
||||
'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png,jpg,mp3}',
|
||||
'out-build/vs/code/browser/workbench/*.html',
|
||||
|
||||
4
src/bootstrap-amd.js
vendored
4
src/bootstrap-amd.js
vendored
@ -73,7 +73,7 @@ function setupNLS() {
|
||||
* @returns {Promise<INLSConfiguration | undefined>}
|
||||
*/
|
||||
async function doSetupNLS() {
|
||||
performance.mark('code/fork/willLoadNls');
|
||||
performance.mark('code/amd/willLoadNls');
|
||||
|
||||
/** @type {INLSConfiguration | undefined} */
|
||||
let nlsConfig = undefined;
|
||||
@ -130,7 +130,7 @@ async function doSetupNLS() {
|
||||
}
|
||||
}
|
||||
|
||||
performance.mark('code/fork/didLoadNls');
|
||||
performance.mark('code/amd/didLoadNls');
|
||||
|
||||
return nlsConfig;
|
||||
}
|
||||
|
||||
15
src/main.js
15
src/main.js
@ -16,7 +16,7 @@ const perf = require('./vs/base/common/performance');
|
||||
perf.mark('code/didStartMain');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const fs = require('original-fs');
|
||||
const os = require('os');
|
||||
const bootstrap = require('./bootstrap');
|
||||
const bootstrapNode = require('./bootstrap-node');
|
||||
@ -215,6 +215,7 @@ function configureCommandlineSwitchesSync(cliArgs) {
|
||||
];
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
|
||||
// Force enable screen readers on Linux via this flag
|
||||
SUPPORTED_ELECTRON_SWITCHES.push('force-renderer-accessibility');
|
||||
|
||||
@ -589,16 +590,6 @@ function getCodeCachePath() {
|
||||
return path.join(userDataPath, 'CachedData', commit);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} dir
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
function mkdirp(dir) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.mkdir(dir, { recursive: true }, err => (err && err.code !== 'EEXIST') ? reject(err) : resolve(dir));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | undefined} dir
|
||||
* @returns {Promise<string | undefined>}
|
||||
@ -606,7 +597,7 @@ function mkdirp(dir) {
|
||||
async function mkdirpIgnoreError(dir) {
|
||||
if (typeof dir === 'string') {
|
||||
try {
|
||||
await mkdirp(dir);
|
||||
await fs.promises.mkdir(dir, { recursive: true });
|
||||
|
||||
return dir;
|
||||
} catch (error) {
|
||||
|
||||
@ -45,35 +45,6 @@
|
||||
return fs.promises.utimes(path, date, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
*/
|
||||
function mkdirp(path) {
|
||||
return fs.promises.mkdir(path, { recursive: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
*/
|
||||
function rimraf(path) {
|
||||
return fs.promises.rm(path, { recursive: true, force: true, maxRetries: 3 });
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
*/
|
||||
function readFile(path) {
|
||||
return fs.promises.readFile(path, 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @param {string} content
|
||||
*/
|
||||
function writeFile(path, content) {
|
||||
return fs.promises.writeFile(path, content, 'utf-8');
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
@ -90,7 +61,7 @@
|
||||
async function getLanguagePackConfigurations(userDataPath) {
|
||||
const configFile = path.join(userDataPath, 'languagepacks.json');
|
||||
try {
|
||||
return JSON.parse(await readFile(configFile));
|
||||
return JSON.parse(await fs.promises.readFile(configFile, 'utf-8'));
|
||||
} catch (err) {
|
||||
return undefined; // Do nothing. If we can't read the file we have no language pack config.
|
||||
}
|
||||
@ -152,7 +123,7 @@
|
||||
if (
|
||||
process.env['VSCODE_DEV'] ||
|
||||
userLocale === 'pseudo' ||
|
||||
userLocale === 'en' || userLocale === 'en-us' ||
|
||||
userLocale.startsWith('en') ||
|
||||
!commit ||
|
||||
!userDataPath
|
||||
) {
|
||||
@ -190,7 +161,7 @@
|
||||
const languagePackCorruptMarkerFile = path.join(globalLanguagePackCachePath, 'corrupted.info');
|
||||
|
||||
if (await exists(languagePackCorruptMarkerFile)) {
|
||||
await rimraf(globalLanguagePackCachePath); // delete corrupted cache folder
|
||||
await fs.promises.rm(globalLanguagePackCachePath, { recursive: true, force: true, maxRetries: 3 }); // delete corrupted cache folder
|
||||
}
|
||||
|
||||
/** @type {INLSConfiguration} */
|
||||
@ -230,10 +201,10 @@
|
||||
nlsDefaultMessages,
|
||||
nlsPackdata
|
||||
] = await Promise.all([
|
||||
mkdirp(commitLanguagePackCachePath),
|
||||
JSON.parse(await readFile(path.join(nlsMetadataPath, 'nls.keys.json'))),
|
||||
JSON.parse(await readFile(path.join(nlsMetadataPath, 'nls.messages.json'))),
|
||||
JSON.parse(await readFile(mainLanguagePackPath))
|
||||
fs.promises.mkdir(commitLanguagePackCachePath, { recursive: true }),
|
||||
JSON.parse(await fs.promises.readFile(path.join(nlsMetadataPath, 'nls.keys.json'), 'utf-8')),
|
||||
JSON.parse(await fs.promises.readFile(path.join(nlsMetadataPath, 'nls.messages.json'), 'utf-8')),
|
||||
JSON.parse(await fs.promises.readFile(mainLanguagePackPath, 'utf-8'))
|
||||
]);
|
||||
|
||||
/** @type {string[]} */
|
||||
@ -254,8 +225,8 @@
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
writeFile(languagePackMessagesFile, JSON.stringify(nlsResult)),
|
||||
writeFile(translationsConfigFile, JSON.stringify(languagePack.translations))
|
||||
fs.promises.writeFile(languagePackMessagesFile, JSON.stringify(nlsResult), 'utf-8'),
|
||||
fs.promises.writeFile(translationsConfigFile, JSON.stringify(languagePack.translations), 'utf-8')
|
||||
]);
|
||||
|
||||
perf.mark('code/didGenerateNls');
|
||||
|
||||
@ -103,7 +103,7 @@ class NativeLocalizationWorkbenchContribution extends BaseLocalizationWorkbenchC
|
||||
if (!this.galleryService.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (!language || !locale || locale === 'en' || locale.indexOf('en-') === 0) {
|
||||
if (!language || !locale || platform.Language.isDefaultVariant()) {
|
||||
return;
|
||||
}
|
||||
if (locale.startsWith(language) || languagePackSuggestionIgnoreList.includes(locale)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user