Skip to content

Commit 27b12af

Browse files
committed
Localize PHP plugin
1 parent 74de3be commit 27b12af

6 files changed

Lines changed: 33 additions & 4 deletions

File tree

extensions/php/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"engines": { "vscode": "*" },
66
"activationEvents": ["onLanguage:php"],
77
"main": "./out/phpMain",
8+
"dependencies": {
9+
"vscode-nls": "^1.0.4"
10+
},
811
"contributes": {
912
"languages": [{
1013
"id": "php",

extensions/php/src/features/utils/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Throttler<T> {
103103
export class Delayer<T> {
104104

105105
public defaultDelay: number;
106-
private timeout: number;
106+
private timeout: NodeJS.Timer;
107107
private completionPromise: Promise<T>;
108108
private onResolve: (value: T | Thenable<T>) => void;
109109
private task: ITask<T>;

extensions/php/src/features/validationProvider.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import * as vscode from 'vscode';
1111

1212
import { ThrottledDelayer } from './utils/async';
1313

14+
import * as nls from 'vscode-nls';
15+
let localize = nls.loadMessageBundle();
16+
1417
export class LineDecoder {
1518
private stringDecoder: NodeStringDecoder;
1619
private remaining: string;
@@ -223,9 +226,9 @@ export default class PHPValidationProvider {
223226
private showError(error: any, executable: string): void {
224227
let message: string = null;
225228
if (error.code === 'ENOENT') {
226-
message = `Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'`;
229+
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\'');
227230
} else {
228-
message = error.message ? error.message : `Failed to run php using path: ${executable}. Reason is unknown.`;
231+
message = error.message ? error.message : localize('unknownReason', 'Failed to run php using path: {0}. Reason is unknown.', executable);
229232
}
230233
vscode.window.showInformationMessage(message);
231234
}

extensions/php/src/phpMain.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import PHPCompletionItemProvider from './features/completionItemProvider';
99
import PHPHoverProvider from './features/hoverProvider';
1010
import PHPSignatureHelpProvider from './features/signatureHelpProvider';
1111
import PHPValidationProvider from './features/validationProvider';
12-
import {ExtensionContext, languages} from 'vscode';
12+
import { ExtensionContext, languages, env } from 'vscode';
13+
14+
import * as nls from 'vscode-nls';
1315

1416
export function activate(context: ExtensionContext): any {
17+
nls.config({locale: env.language});
1518

1619
// add providers
1720
context.subscriptions.push(languages.registerCompletionItemProvider('php', new PHPCompletionItemProvider(), '.', ':', '$'));
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
7+
declare function clearTimeout(timeoutId: NodeJS.Timer): void;
8+
declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
9+
declare function clearInterval(intervalId: NodeJS.Timer): void;
10+
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
11+
declare function clearImmediate(immediateId: any): void;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/// <reference path='../../../../src/vs/vscode.d.ts'/>
7+
/// <reference path='../../../../src/typings/mocha.d.ts'/>
8+
/// <reference path='../../../../extensions/node.d.ts'/>
9+
/// <reference path='../../../../extensions/lib.core.d.ts'/>

0 commit comments

Comments
 (0)