Skip to content

Commit 86e4898

Browse files
committed
feat: localize LSP server messages and drop the "(LSP)" tag from Problems panel
- Forward the user's UI locale (brackets.getLocale()) as LSP InitializeParams.locale on initialize, so vtsls/tsserver emit their diagnostics and hover/quick-info text in the user's language. Unknown locales fall back to English, so this is safe everywhere. - Name the CodeInspection provider after the bare server id (e.g. "typescript") instead of "<id> (LSP)". The Problems panel read "0 typescript (LSP) Problems"; to the user this is just built-in language support, and the LSP backing is an internal detail they don't need to see. The same id still drives the registered-inspector guard, so behaviour is unchanged.
1 parent e0ca832 commit 86e4898

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/languageTools/LSPClient.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ define(function (require, exports, module) {
507507
};
508508
}
509509

510+
// The UI language the user has Phoenix set to (e.g. "en", "fr", "ja"), forwarded to the
511+
// server so it can localize its messages. Falls back to English when unavailable.
512+
function _uiLocale() {
513+
return (typeof brackets !== "undefined" && brackets.getLocale && brackets.getLocale()) || "en";
514+
}
515+
510516
async function _startAndInit(client) {
511517
const config = client.config;
512518
const conn = await getConnector();
@@ -526,6 +532,10 @@ define(function (require, exports, module) {
526532
method: "initialize",
527533
params: {
528534
processId: null,
535+
// LSP InitializeParams.locale - the UI language to localize server messages
536+
// (diagnostics, hover/quick-info) in. vtsls forwards this to tsserver, which ships
537+
// localized messages for many locales and falls back to English for unknown ones.
538+
locale: _uiLocale(),
529539
rootUri: rootUri,
530540
workspaceFolders: rootUri ? [{ uri: rootUri, name: rootName }] : null,
531541
capabilities: _clientCapabilities(),
@@ -550,9 +560,9 @@ define(function (require, exports, module) {
550560
client.references = new DefaultProviders.ReferencesProvider(client);
551561
client.lintingProvider = new DefaultProviders.LintingProvider();
552562
client.lintingProvider._validateOnType = true;
553-
// Record the CodeInspection registration name so the provider can tell whether it is
554-
// still a participating inspector before nudging a re-run on async diagnostics.
555-
client.lintingProvider._inspectionProviderName = client.serverId + " (LSP)";
563+
// recorded so the provider can tell whether it is still a participating inspector before nudging a
564+
// re-run on async diagnostics.
565+
client.lintingProvider._inspectionProviderName = client.serverId;
556566
client.hover = new HoverProvider.HoverProvider(client);
557567

558568
CodeHintManager.registerHintProvider(client.codeHints, langs, DEFAULT_PRIORITY);

0 commit comments

Comments
 (0)