2 /* --------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All rights reserved.
4 * Licensed under the MIT License. See License.txt in the project root for license information.
5 * ------------------------------------------------------------------------------------------ */
6 Object.defineProperty(exports, "__esModule", { value: true });
7 exports.config = exports.loadMessageBundle = exports.localize = exports.format = exports.setPseudo = exports.isPseudo = exports.isDefined = exports.BundleFormat = exports.MessageFormat = void 0;
8 var ral_1 = require("./ral");
10 (function (MessageFormat) {
11 MessageFormat["file"] = "file";
12 MessageFormat["bundle"] = "bundle";
13 MessageFormat["both"] = "both";
14 })(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {}));
16 (function (BundleFormat) {
17 // the nls.bundle format
18 BundleFormat["standalone"] = "standalone";
19 BundleFormat["languagePack"] = "languagePack";
20 })(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {}));
22 (function (LocalizeInfo) {
24 var candidate = value;
25 return candidate && isDefined(candidate.key) && isDefined(candidate.comment);
28 })(LocalizeInfo || (LocalizeInfo = {}));
29 function isDefined(value) {
30 return typeof value !== 'undefined';
32 exports.isDefined = isDefined;
33 exports.isPseudo = false;
34 function setPseudo(pseudo) {
35 exports.isPseudo = pseudo;
37 exports.setPseudo = setPseudo;
38 function format(message, args) {
40 if (exports.isPseudo) {
41 // FF3B and FF3D is the Unicode zenkaku representation for [ and ]
42 message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D';
44 if (args.length === 0) {
48 result = message.replace(/\{(\d+)\}/g, function (match, rest) {
50 var arg = args[index];
51 var replacement = match;
52 if (typeof arg === 'string') {
55 else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {
56 replacement = String(arg);
63 exports.format = format;
64 function localize(_key, message) {
66 for (var _i = 2; _i < arguments.length; _i++) {
67 args[_i - 2] = arguments[_i];
69 return format(message, args);
71 exports.localize = localize;
72 function loadMessageBundle(file) {
73 return ral_1.default().loadMessageBundle(file);
75 exports.loadMessageBundle = loadMessageBundle;
76 function config(opts) {
77 return ral_1.default().config(opts);
79 exports.config = config;
80 //# sourceMappingURL=common.js.map