Localize PHP plugin

This commit is contained in:
Dirk Baeumer 2016-03-03 15:12:19 +01:00
parent 74de3be44d
commit 27b12afea4
6 changed files with 33 additions and 4 deletions

View file

@ -5,6 +5,9 @@
"engines": { "vscode": "*" },
"activationEvents": ["onLanguage:php"],
"main": "./out/phpMain",
"dependencies": {
"vscode-nls": "^1.0.4"
},
"contributes": {
"languages": [{
"id": "php",

View file

@ -103,7 +103,7 @@ export class Throttler<T> {
export class Delayer<T> {
public defaultDelay: number;
private timeout: number;
private timeout: NodeJS.Timer;
private completionPromise: Promise<T>;
private onResolve: (value: T | Thenable<T>) => void;
private task: ITask<T>;

View file

@ -11,6 +11,9 @@ import * as vscode from 'vscode';
import { ThrottledDelayer } from './utils/async';
import * as nls from 'vscode-nls';
let localize = nls.loadMessageBundle();
export class LineDecoder {
private stringDecoder: NodeStringDecoder;
private remaining: string;
@ -223,9 +226,9 @@ export default class PHPValidationProvider {
private showError(error: any, executable: string): void {
let message: string = null;
if (error.code === 'ENOENT') {
message = `Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'`;
message = localize('noPHP', 'Cannot validate the php file. The php program was not found. Use the \'php.validate.executablePath\' setting to configure the location of \'php\'');
} else {
message = error.message ? error.message : `Failed to run php using path: ${executable}. Reason is unknown.`;
message = error.message ? error.message : localize('unknownReason', 'Failed to run php using path: {0}. Reason is unknown.', executable);
}
vscode.window.showInformationMessage(message);
}

View file

@ -9,9 +9,12 @@ import PHPCompletionItemProvider from './features/completionItemProvider';
import PHPHoverProvider from './features/hoverProvider';
import PHPSignatureHelpProvider from './features/signatureHelpProvider';
import PHPValidationProvider from './features/validationProvider';
import {ExtensionContext, languages} from 'vscode';
import { ExtensionContext, languages, env } from 'vscode';
import * as nls from 'vscode-nls';
export function activate(context: ExtensionContext): any {
nls.config({locale: env.language});
// add providers
context.subscriptions.push(languages.registerCompletionItemProvider('php', new PHPCompletionItemProvider(), '.', ':', '$'));

View file

@ -0,0 +1,11 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
declare function clearInterval(intervalId: NodeJS.Timer): void;
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
declare function clearImmediate(immediateId: any): void;

9
extensions/php/src/typings/refs.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/typings/mocha.d.ts'/>
/// <reference path='../../../../extensions/node.d.ts'/>
/// <reference path='../../../../extensions/lib.core.d.ts'/>