提交 cf6884c0 编写于 作者: J Joao Moreno

refactgor bootstrap-amd

上级 cf1e93a5
......@@ -4,51 +4,10 @@
*--------------------------------------------------------------------------------------------*/
var path = require('path');
var fs = require('fs');
var app = require('electron').app;
var loader = require('./vs/loader');
// Duplicated in ../index.html for the renderes.
function getNLSConfiguration() {
if (process.env['VSCODE_NLS_CONFIG']) {
return JSON.parse(process.env['VSCODE_NLS_CONFIG']);
}
var locale = undefined;
var localeOpts = '--locale';
for (var i = 0; i < process.argv.length; i++) {
var arg = process.argv[i];
if (arg.slice(0, localeOpts.length) == localeOpts) {
var segments = arg.split('=');
locale = segments[1];
break;
}
}
if (locale === 'pseudo') {
return { availableLanguages: {}, pseudo: true }
}
if (process.env.VSCODE_DEV) {
return { availableLanguages: {} };
}
// We have a built version so we have extracted nls file. Try to find
// the right file to use.
locale = locale || app.getLocale();
while (locale) {
var candidate = path.join(__dirname, 'main.nls.') + locale + '.js';
if (fs.existsSync(candidate)) {
return { availableLanguages: { '*': locale } };
} else {
var index = locale.lastIndexOf('-');
if (index > 0) {
locale = locale.substring(0, index);
} else {
locale = null;
}
}
}
return { availableLanguages: {} };
}
function uriFromPath(_path) {
var pathName = path.resolve(_path).replace(/\\/g, '/');
......@@ -59,8 +18,8 @@ function uriFromPath(_path) {
return encodeURI('file://' + pathName);
}
var nlsConfig = getNLSConfiguration();
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
var nlsConfig = rawNlsConfig ? JSON.parse(rawNlsConfig) : { availableLanguages:{} };
loader.config({
baseUrl: uriFromPath(path.join(__dirname)),
......
......@@ -7,8 +7,48 @@
global.vscodeStart = Date.now();
var app = require('electron').app;
var fs = require('fs');
var path = require('path');
// Duplicated in ../index.html for the renderes.
function getNLSConfiguration() {
var locale = undefined;
var localeOpts = '--locale';
for (var i = 0; i < process.argv.length; i++) {
var arg = process.argv[i];
if (arg.slice(0, localeOpts.length) == localeOpts) {
var segments = arg.split('=');
locale = segments[1];
break;
}
}
if (locale === 'pseudo') {
return { availableLanguages: {}, pseudo: true }
}
if (process.env.VSCODE_DEV) {
return { availableLanguages: {} };
}
// We have a built version so we have extracted nls file. Try to find
// the right file to use.
locale = locale || app.getLocale();
while (locale) {
var candidate = path.join(__dirname, 'main.nls.') + locale + '.js';
if (fs.existsSync(candidate)) {
return { availableLanguages: { '*': locale } };
} else {
var index = locale.lastIndexOf('-');
if (index > 0) {
locale = locale.substring(0, index);
} else {
locale = null;
}
}
}
return { availableLanguages: {} };
}
// Change cwd if given via env variable
try {
if (process.env.VSCODE_CWD) {
......@@ -31,6 +71,9 @@ app.on('open-file', function(event, path) {
global.macOpenFiles.push(path);
});
var nlsConfig = getNLSConfiguration();
process.env['VSCODE_NLS_CONFIG'] = JSON.stringify(nlsConfig);
// Load our code once ready
app.once('ready', function() {
process.env['AMD_ENTRYPOINT'] = 'vs/workbench/electron-main/main';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册