diff --git a/src/vs/code/electron-main/logUploader.ts b/src/vs/code/electron-main/logUploader.ts index 62f8df133a39245bcd4897db233125ba067beb4e..581749975cd77b203bfe86e03e31731ba5a3d826 100644 --- a/src/vs/code/electron-main/logUploader.ts +++ b/src/vs/code/electron-main/logUploader.ts @@ -126,7 +126,7 @@ function zipLogs( return new TPromise((resolve, reject) => { doZip(logsPath, outZip, tempDir, (err, stdout, stderr) => { if (err) { - console.error(localize('zipError', 'Error zipping logs: {0}', err)); + console.error(localize('zipError', 'Error zipping logs: {0}', err.message)); reject(err); } else { resolve(outZip); diff --git a/src/vs/nls.d.ts b/src/vs/nls.d.ts index eae07d0b2158ceb12b0dfc80c6c03b495f67abaa..38bbd076068b4623623b28afc0be83fc85242c4e 100644 --- a/src/vs/nls.d.ts +++ b/src/vs/nls.d.ts @@ -8,5 +8,5 @@ export interface ILocalizeInfo { comment: string[]; } -export declare function localize(info: ILocalizeInfo, message: string, ...args: any[]): string; -export declare function localize(key: string, message: string, ...args: any[]): string; +export declare function localize(info: ILocalizeInfo, message: string, ...args: (string | number | boolean | undefined | null)[]): string; +export declare function localize(key: string, message: string, ...args: (string | number | boolean | undefined | null)[]): string; diff --git a/src/vs/nls.js b/src/vs/nls.js index 79b64a2248454c5080dde48edec45f3e735174e9..8e178e8d0ea24238ea512696682f22c317bd0c59 100644 --- a/src/vs/nls.js +++ b/src/vs/nls.js @@ -46,7 +46,15 @@ var NLSLoaderPlugin; else { result = message.replace(/\{(\d+)\}/g, function (match, rest) { var index = rest[0]; - return typeof args[index] !== 'undefined' ? args[index] : match; + var arg = args[index]; + var result = match; + if (typeof arg === 'string') { + result = arg; + } + else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) { + result = String(arg); + } + return result; }); } if (env.isPseudo) { diff --git a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts index aa936863ad350aed83e5a5a14b7b3284266ce129..2055bda2c70cd3f19aa27200f29d15d3b1b3e3e1 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts @@ -213,7 +213,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant { const versionNow = model.getVersionId(); const { tabSize, insertSpaces } = model.getOptions(); - const timeout = this._configurationService.getValue('editor.formatOnSaveTimeout', { overrideIdentifier: model.getLanguageIdentifier().language, resource: editorModel.getResource() }); + const timeout = this._configurationService.getValue('editor.formatOnSaveTimeout', { overrideIdentifier: model.getLanguageIdentifier().language, resource: editorModel.getResource() }); return new Promise((resolve, reject) => { let source = new CancellationTokenSource(); diff --git a/src/vs/workbench/parts/codeEditor/electron-browser/languageConfiguration/languageConfigurationExtensionPoint.ts b/src/vs/workbench/parts/codeEditor/electron-browser/languageConfiguration/languageConfigurationExtensionPoint.ts index f7b4b58542172e3a7d3a4ef4d236df374b0aa91d..a7f79a6be50973060f1d4e73a6d11c9f412401f8 100644 --- a/src/vs/workbench/parts/codeEditor/electron-browser/languageConfiguration/languageConfigurationExtensionPoint.ts +++ b/src/vs/workbench/parts/codeEditor/electron-browser/languageConfiguration/languageConfigurationExtensionPoint.ts @@ -94,7 +94,7 @@ export class LanguageConfigurationFileHandler { const errors: ParseError[] = []; const configuration = parse(contents.value.toString(), errors); if (errors.length) { - console.error(nls.localize('parseErrors', "Errors parsing {0}: {1}", configFileLocation, errors.join('\n'))); + console.error(nls.localize('parseErrors', "Errors parsing {0}: {1}", configFileLocation.toString(), errors.join('\n'))); } this._handleConfig(languageIdentifier, configuration); }, (err) => { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index a101bcd009ba4744ea4b0eae3a9ac73ce21f2212..d310d296c238af74dec19860dbd922a38444f8a0 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -309,7 +309,7 @@ export class DebugService implements IDebugService { })); } if (configOrName && !config) { - const message = !!launch ? nls.localize('configMissing', "Configuration '{0}' is missing in 'launch.json'.", configOrName) : + const message = !!launch ? nls.localize('configMissing', "Configuration '{0}' is missing in 'launch.json'.", typeof configOrName === 'string' ? configOrName : JSON.stringify(configOrName)) : nls.localize('launchJsonDoesNotExist', "'launch.json' does not exist."); return TPromise.wrapError(new Error(message)); } @@ -746,7 +746,7 @@ export class DebugService implements IDebugService { if (!taskStarted) { const errorMessage = typeof taskId === 'string' ? nls.localize('taskNotTrackedWithTaskId', "The specified task cannot be tracked.") - : nls.localize('taskNotTracked', "The task '{0}' cannot be tracked.", taskId); + : nls.localize('taskNotTracked', "The task '{0}' cannot be tracked.", JSON.stringify(taskId)); e({ severity: severity.Error, message: errorMessage }); } }, 10000); diff --git a/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts b/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts index 836e86c0cb34e39d7acdec4e4ea19d1a1c3c0023..c0ea1ded30a2512c5d65e5f49869b50dd8964a1c 100644 --- a/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts +++ b/src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts @@ -202,7 +202,7 @@ class SnippetsService implements ISnippetsService { extension.collector.warn(localize( 'badFile', "The snippet file \"{0}\" could not be read.", - file.location + file.location.toString() )); }); } diff --git a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts index 810cfd8615ba7aafa1ddf422ea8edf80bb5d9dbf..8380beb70b306d2217b9747aacfa5798975e5468 100644 --- a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts @@ -361,7 +361,7 @@ export class ProcessTaskSystem implements ITaskSystem { let makeVisible = false; if (errorData.error && !errorData.terminated) { let args: string = task.command.args ? task.command.args.join(' ') : ''; - this.log(nls.localize('TaskRunnerSystem.childProcessError', 'Failed to launch external program {0} {1}.', task.command.name, args)); + this.log(nls.localize('TaskRunnerSystem.childProcessError', 'Failed to launch external program {0} {1}.', JSON.stringify(task.command.name), args)); this.outputChannel.append(errorData.error.message); makeVisible = true; } diff --git a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts index 6b46b4eb0c3f506cf19665071c9a69cc86383d9a..1abfe0a5b1804925af8a617d04a1999e44bd1f5c 100644 --- a/src/vs/workbench/parts/tasks/node/taskConfiguration.ts +++ b/src/vs/workbench/parts/tasks/node/taskConfiguration.ts @@ -890,7 +890,12 @@ namespace CommandConfiguration { if (converted !== void 0) { result.args.push(converted); } else { - context.problemReporter.error(nls.localize('ConfigurationParser.inValidArg', 'Error: command argument must either be a string or a quoted string. Provided value is:\n{0}', context.problemReporter.error(nls.localize('ConfigurationParser.noargs', 'Error: command arguments must be an array of strings. Provided value is:\n{0}', arg ? JSON.stringify(arg, undefined, 4) : 'undefined')))); + context.problemReporter.error( + nls.localize( + 'ConfigurationParser.inValidArg', + 'Error: command argument must either be a string or a quoted string. Provided value is:\n{0}', + arg ? JSON.stringify(arg, undefined, 4) : 'undefined' + )); } } } diff --git a/src/vs/workbench/services/jsonschemas/common/jsonValidationExtensionPoint.ts b/src/vs/workbench/services/jsonschemas/common/jsonValidationExtensionPoint.ts index 552888adf39c8c9fb6c06812c75b0b75ddcc45b9..4169ec2f48c636fa4d9f64e416922360103f65f6 100644 --- a/src/vs/workbench/services/jsonschemas/common/jsonValidationExtensionPoint.ts +++ b/src/vs/workbench/services/jsonschemas/common/jsonValidationExtensionPoint.ts @@ -61,7 +61,7 @@ export class JSONValidationExtensionPoint { try { const colorThemeLocation = resources.joinPath(extensionLocation, uri); if (!resources.isEqualOrParent(colorThemeLocation, extensionLocation)) { - collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.url` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", configurationExtPoint.name, location, extensionLocation.path)); + collector.warn(nls.localize('invalid.path.1', "Expected `contributes.{0}.url` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.", configurationExtPoint.name, colorThemeLocation.toString(), extensionLocation.path)); } } catch (e) { collector.error(nls.localize('invalid.url.fileschema', "'configuration.jsonValidation.url' is an invalid relative URL: {0}", e.message)); diff --git a/src/vs/workbench/services/themes/electron-browser/colorThemeData.ts b/src/vs/workbench/services/themes/electron-browser/colorThemeData.ts index ffbe58cf3b0a443594c56ecabe3382a214b03c58..81c979f3f8a56dff6798f669a7bb1728ad592f73 100644 --- a/src/vs/workbench/services/themes/electron-browser/colorThemeData.ts +++ b/src/vs/workbench/services/themes/electron-browser/colorThemeData.ts @@ -293,7 +293,7 @@ function _loadColorTheme(fileService: IFileService, themeLocation: URI, resultRu let colors = contentValue.colors; if (colors) { if (typeof colors !== 'object') { - return TPromise.wrapError(new Error(nls.localize({ key: 'error.invalidformat.colors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'colors' is not of type 'object'.", themeLocation))); + return TPromise.wrapError(new Error(nls.localize({ key: 'error.invalidformat.colors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'colors' is not of type 'object'.", themeLocation.toString()))); } // new JSON color themes format for (let colorId in colors) { @@ -311,7 +311,7 @@ function _loadColorTheme(fileService: IFileService, themeLocation: URI, resultRu } else if (typeof tokenColors === 'string') { return _loadSyntaxTokens(fileService, resources.joinPath(resources.dirname(themeLocation), tokenColors), resultRules, {}); } else { - return TPromise.wrapError(new Error(nls.localize({ key: 'error.invalidformat.tokenColors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'tokenColors' should be either an array specifying colors or a path to a TextMate theme file", themeLocation))); + return TPromise.wrapError(new Error(nls.localize({ key: 'error.invalidformat.tokenColors', comment: ['{0} will be replaced by a path. Values in quotes should not be translated.'] }, "Problem parsing color theme file: {0}. Property 'tokenColors' should be either an array specifying colors or a path to a TextMate theme file", themeLocation.toString()))); } } return null; @@ -343,7 +343,7 @@ function _loadSyntaxTokens(fileService: IFileService, themeLocation: URI, result } }); }, error => { - return TPromise.wrapError(new Error(nls.localize('error.cannotload', "Problems loading tmTheme file {0}: {1}", themeLocation, error.message))); + return TPromise.wrapError(new Error(nls.localize('error.cannotload', "Problems loading tmTheme file {0}: {1}", themeLocation.toString(), error.message))); }); } diff --git a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts index 91a9a231ffa002c93656e368704ae04c54f6e8d1..c6af43bc0780b8fb61a4769b7cf50ab96ba98b8c 100644 --- a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts @@ -294,7 +294,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { this.updateDynamicCSSRules(themeData); return this.applyTheme(themeData, settingsTarget); }, error => { - return TPromise.wrapError(new Error(nls.localize('error.cannotloadtheme', "Unable to load {0}: {1}", themeData.location, error.message))); + return TPromise.wrapError(new Error(nls.localize('error.cannotloadtheme', "Unable to load {0}: {1}", themeData.location.toString(), error.message))); }); } return null;