Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/build/polyfills/vscode-nls.js
Joe Previte be3e823608 Squashed 'lib/vscode/' content from commit e5a624b788
git-subtree-dir: lib/vscode
git-subtree-split: e5a624b788d92b8d34d1392e4c4d9789406efe8f
2020-12-15 15:52:33 -07:00

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;