"use strict"; /* -------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ Object.defineProperty(exports, "__esModule", { value: true }); exports.config = exports.loadMessageBundle = exports.localize = exports.format = exports.setPseudo = exports.isPseudo = exports.isDefined = exports.BundleFormat = exports.MessageFormat = void 0; var ral_1 = require("./ral"); var MessageFormat; (function (MessageFormat) { MessageFormat["file"] = "file"; MessageFormat["bundle"] = "bundle"; MessageFormat["both"] = "both"; })(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {})); var BundleFormat; (function (BundleFormat) { // the nls.bundle format BundleFormat["standalone"] = "standalone"; BundleFormat["languagePack"] = "languagePack"; })(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {})); var LocalizeInfo; (function (LocalizeInfo) { function is(value) { var candidate = value; return candidate && isDefined(candidate.key) && isDefined(candidate.comment); } LocalizeInfo.is = is; })(LocalizeInfo || (LocalizeInfo = {})); function isDefined(value) { return typeof value !== 'undefined'; } exports.isDefined = isDefined; exports.isPseudo = false; function setPseudo(pseudo) { exports.isPseudo = pseudo; } exports.setPseudo = setPseudo; function format(message, args) { var result; if (exports.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) { var index = rest[0]; var arg = args[index]; var 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; } exports.format = format; function localize(_key, message) { var args = []; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } return format(message, args); } exports.localize = localize; function loadMessageBundle(file) { return ral_1.default().loadMessageBundle(file); } exports.loadMessageBundle = loadMessageBundle; function config(opts) { return ral_1.default().config(opts); } exports.config = config; //# sourceMappingURL=common.js.map