yaml-language-server
Version:
70 lines • 3.1 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupl10nBundle = setupl10nBundle;
/*---------------------------------------------------------------------------------------------
* Copyright (c) IBM Corp. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = __importStar(require("path"));
const fs_1 = require("fs");
const vscode_uri_1 = require("vscode-uri");
const l10n = __importStar(require("@vscode/l10n"));
/**
* Loads translations from the filesystem based on the configured locale and the folder of translations provided in the initialization parameters.
*
* This is the default implementation when running as binary, but isn't used when running as a web worker.
*
* @param params the language server initialization parameters
*/
async function setupl10nBundle(params) {
const __dirname = path.dirname(__filename);
const l10nPath = params.initializationOptions?.l10nPath || path.join(__dirname, '../../../l10n');
const locale = params.locale || 'en';
if (l10nPath) {
const bundleFile = !(0, fs_1.existsSync)(path.join(l10nPath, `bundle.l10n.${locale}.json`))
? `bundle.l10n.json`
: `bundle.l10n.${locale}.json`;
const baseBundleFile = path.join(l10nPath, bundleFile);
process.env.VSCODE_NLS_CONFIG = JSON.stringify({
locale,
_languagePackSupport: true,
});
await l10n.config({
uri: vscode_uri_1.URI.file(baseBundleFile).toString(),
});
}
}
//# sourceMappingURL=nodeTranslationSetup.js.map