Skip to content

Commit 01ca741

Browse files
committed
Fix the fallback path to the l10n folder
If the language server client doesn't specify the location of the l10n folder, then the language server falls back to a path relative to the complied file. This path was wrong; `server.js` is in `./out/server/src/server.js`, so the relative path of the `l10n` folder is `../../../l10n` instead of `../l10n`. Signed-off-by: David Thompson <[email protected]>
1 parent 5215810 commit 01ca741

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/yamlServerInit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class YAMLServerInit {
5959

6060
public async setupl10nBundle(params: InitializeParams): Promise<void> {
6161
const __dirname = path.dirname(__filename);
62-
const l10nPath: string = params.initializationOptions?.l10nPath || path.join(__dirname, '../l10n');
62+
const l10nPath: string = params.initializationOptions?.l10nPath || path.join(__dirname, '../../../l10n');
6363
const locale: string = params.locale || 'en';
6464
if (l10nPath) {
6565
const bundleFile = !fs.existsSync(path.join(l10nPath, `bundle.l10n.${locale}.json`))

test/bundlel10n.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { schemaRequestHandler, workspaceContext } from '../src/languageservice/s
1010
import { TestTelemetry } from './utils/testsTypes';
1111
import { YAMLServerInit } from '../src/yamlServerInit';
1212
import * as l10n from '@vscode/l10n';
13+
import * as path from 'path';
1314

1415
describe('Bundle l10n Test', () => {
1516
let serverInit: YAMLServerInit;
@@ -44,6 +45,9 @@ describe('Bundle l10n Test', () => {
4445
processId: 0,
4546
rootUri: '',
4647
capabilities: undefined,
48+
initializationOptions: {
49+
l10nPath: path.join(__dirname, '../l10n'),
50+
},
4751
});
4852
});
4953

@@ -54,6 +58,9 @@ describe('Bundle l10n Test', () => {
5458
processId: 0,
5559
rootUri: '',
5660
capabilities: undefined,
61+
initializationOptions: {
62+
l10nPath: path.join(__dirname, '../l10n'),
63+
},
5764
});
5865
assert.equal(l10n.t('Default Value'), 'Valeur par défaut');
5966
});
@@ -64,6 +71,9 @@ describe('Bundle l10n Test', () => {
6471
processId: 0,
6572
rootUri: '',
6673
capabilities: undefined,
74+
initializationOptions: {
75+
l10nPath: path.join(__dirname, '../l10n'),
76+
},
6777
});
6878
assert.equal(l10n.t('Default Value'), 'Default value');
6979
});

0 commit comments

Comments
 (0)