1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 20:55:25 +00:00
code-server-2/lib/vscode/build/polyfills/vscode-nls.js

80 lines
2.3 KiB
JavaScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
function format(message, args) {
let result;
// if (isPseudo) {
// // FF3B and FF3D is the Unicode zenkaku representation for [ and ]
// message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D';
// }
if (args.length === 0) {
result = message;
}
else {
result = message.replace(/\{(\d+)\}/g, function (match, rest) {
let index = rest[0];
let arg = args[index];
let replacement = match;
if (typeof arg === 'string') {
replacement = arg;
}
else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {
replacement = String(arg);
}
return replacement;
});
}
return result;
}
function localize(key, message) {
let args = [];
for (let _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
return format(message, args);
}
function loadMessageBundle(file) {
return localize;
}
let MessageFormat;
(function (MessageFormat) {
MessageFormat["file"] = "file";
MessageFormat["bundle"] = "bundle";
MessageFormat["both"] = "both";
})(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {}));
let BundleFormat;
(function (BundleFormat) {
// the nls.bundle format
BundleFormat["standalone"] = "standalone";
BundleFormat["languagePack"] = "languagePack";
})(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {}));
exports.loadMessageBundle = loadMessageBundle;
function config(opts) {
if (opts) {
if (isString(opts.locale)) {
options.locale = opts.locale.toLowerCase();
options.language = options.locale;
resolvedLanguage = undefined;
resolvedBundles = Object.create(null);
}
if (opts.messageFormat !== undefined) {
options.messageFormat = opts.messageFormat;
}
if (opts.bundleFormat === BundleFormat.standalone && options.languagePackSupport === true) {
options.languagePackSupport = false;
}
}
isPseudo = options.locale === 'pseudo';
return loadMessageBundle;
}
exports.config = config;