Skip to content

Commit 604808b

Browse files
committed
fix vs/nls
1 parent 4d64578 commit 604808b

1 file changed

Lines changed: 120 additions & 114 deletions

File tree

src/vs/nls.js

Lines changed: 120 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,126 @@
11
/*---------------------------------------------------------------------------------------------
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
4-
*--------------------------------------------------------------------------------------------*/
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
55
/*---------------------------------------------------------------------------------------------
6-
*---------------------------------------------------------------------------------------------
7-
*---------------------------------------------------------------------------------------------
8-
*---------------------------------------------------------------------------------------------
9-
*---------------------------------------------------------------------------------------------
10-
* Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
11-
*---------------------------------------------------------------------------------------------
12-
*---------------------------------------------------------------------------------------------
13-
*---------------------------------------------------------------------------------------------
14-
*---------------------------------------------------------------------------------------------
15-
*--------------------------------------------------------------------------------------------*/
6+
*---------------------------------------------------------------------------------------------
7+
*---------------------------------------------------------------------------------------------
8+
*---------------------------------------------------------------------------------------------
9+
*---------------------------------------------------------------------------------------------
10+
* Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
11+
*---------------------------------------------------------------------------------------------
12+
*---------------------------------------------------------------------------------------------
13+
*---------------------------------------------------------------------------------------------
14+
*---------------------------------------------------------------------------------------------
15+
*--------------------------------------------------------------------------------------------*/
1616
'use strict';
1717
var NLSLoaderPlugin;
1818
(function (NLSLoaderPlugin) {
19-
var Environment = (function () {
20-
function Environment(isPseudo) {
21-
this.isPseudo = isPseudo;
22-
//
23-
}
24-
Environment.detect = function () {
25-
var isPseudo = (typeof document !== 'undefined' && document.location && document.location.hash.indexOf('pseudo=true') >= 0);
26-
return new Environment(isPseudo);
27-
};
28-
return Environment;
29-
}());
30-
function _format(message, args, env) {
31-
var result;
32-
if (args.length === 0) {
33-
result = message;
34-
}
35-
else {
36-
result = message.replace(/\{(\d+)\}/g, function (match, rest) {
37-
var index = rest[0];
38-
return typeof args[index] !== 'undefined' ? args[index] : match;
39-
});
40-
}
41-
if (env.isPseudo) {
42-
// FF3B and FF3D is the Unicode zenkaku representation for [ and ]
43-
result = '\uFF3B' + result.replace(/[aouei]/g, '$&$&') + '\uFF3D';
44-
}
45-
return result;
46-
}
47-
function findLanguageForModule(config, name) {
48-
var result = config[name];
49-
if (result)
50-
return result;
51-
result = config['*'];
52-
if (result)
53-
return result;
54-
return null;
55-
}
56-
function localize(data, message, env) {
57-
var args = [];
58-
for (var _i = 0; _i < (arguments.length - 2); _i++) {
59-
args[_i] = arguments[_i + 2];
60-
}
61-
return _format(message, args, env);
62-
}
63-
function createScopedLocalize(scope, env) {
64-
return function (idx, defaultValue) {
65-
var restArgs = Array.prototype.slice.call(arguments, 2);
66-
return _format(scope[idx], restArgs, env);
67-
};
68-
}
69-
var NLSPlugin = (function () {
70-
function NLSPlugin(env) {
71-
var _this = this;
72-
this._env = env;
73-
this.localize = function (data, message) { return localize(data, message, _this._env); };
74-
}
75-
NLSPlugin.prototype.setPseudoTranslation = function (value) {
76-
this._env = new Environment(value);
77-
};
78-
NLSPlugin.prototype.create = function (key, data) {
79-
return {
80-
localize: createScopedLocalize(data[key], this._env)
81-
};
82-
};
83-
NLSPlugin.prototype.load = function (name, req, load, config) {
84-
var _this = this;
85-
config = config || {};
86-
if (!name || name.length === 0) {
87-
load({
88-
localize: localize
89-
});
90-
}
91-
else {
92-
var pluginConfig = config['vs/nls'] || {};
93-
var language = pluginConfig.availableLanguages ? findLanguageForModule(pluginConfig.availableLanguages, name) : null;
94-
var suffix = '.nls';
95-
if (language !== null && language !== NLSPlugin.DEFAULT_TAG) {
96-
suffix = suffix + '.' + language;
97-
}
98-
req([name + suffix], function (messages) {
99-
if (Array.isArray(messages)) {
100-
messages.localize = createScopedLocalize(messages, _this._env);
101-
}
102-
else {
103-
messages.localize = createScopedLocalize(messages[name], _this._env);
104-
}
105-
load(messages);
106-
});
107-
}
108-
};
109-
return NLSPlugin;
110-
}());
111-
NLSPlugin.DEFAULT_TAG = 'i-default';
112-
NLSLoaderPlugin.NLSPlugin = NLSPlugin;
113-
function init() {
114-
define('vs/nls', new NLSPlugin(Environment.detect()));
115-
}
116-
NLSLoaderPlugin.init = init;
117-
if (typeof doNotInitLoader === 'undefined') {
118-
init();
119-
}
19+
var Environment = (function () {
20+
function Environment(isPseudo) {
21+
this.isPseudo = isPseudo;
22+
//
23+
}
24+
Environment.detect = function () {
25+
var isPseudo = (typeof document !== 'undefined' && document.location && document.location.hash.indexOf('pseudo=true') >= 0);
26+
return new Environment(isPseudo);
27+
};
28+
return Environment;
29+
}());
30+
function _format(message, args, env) {
31+
var result;
32+
if (args.length === 0) {
33+
result = message;
34+
}
35+
else {
36+
result = message.replace(/\{(\d+)\}/g, function (match, rest) {
37+
var index = rest[0];
38+
return typeof args[index] !== 'undefined' ? args[index] : match;
39+
});
40+
}
41+
if (env.isPseudo) {
42+
// FF3B and FF3D is the Unicode zenkaku representation for [ and ]
43+
result = '\uFF3B' + result.replace(/[aouei]/g, '$&$&') + '\uFF3D';
44+
}
45+
return result;
46+
}
47+
function findLanguageForModule(config, name) {
48+
var result = config[name];
49+
if (result)
50+
return result;
51+
result = config['*'];
52+
if (result)
53+
return result;
54+
return null;
55+
}
56+
function localize(env, data, message) {
57+
var args = [];
58+
for (var _i = 3; _i < arguments.length; _i++) {
59+
args[_i - 3] = arguments[_i];
60+
}
61+
return _format(message, args, env);
62+
}
63+
function createScopedLocalize(scope, env) {
64+
return function (idx, defaultValue) {
65+
var restArgs = Array.prototype.slice.call(arguments, 2);
66+
return _format(scope[idx], restArgs, env);
67+
};
68+
}
69+
var NLSPlugin = (function () {
70+
function NLSPlugin(env) {
71+
var _this = this;
72+
this._env = env;
73+
this.localize = function (data, message) {
74+
var args = [];
75+
for (var _i = 2; _i < arguments.length; _i++) {
76+
args[_i - 2] = arguments[_i];
77+
}
78+
return localize.apply(void 0, [_this._env, data, message].concat(args));
79+
};
80+
}
81+
NLSPlugin.prototype.setPseudoTranslation = function (value) {
82+
this._env = new Environment(value);
83+
};
84+
NLSPlugin.prototype.create = function (key, data) {
85+
return {
86+
localize: createScopedLocalize(data[key], this._env)
87+
};
88+
};
89+
NLSPlugin.prototype.load = function (name, req, load, config) {
90+
var _this = this;
91+
config = config || {};
92+
if (!name || name.length === 0) {
93+
load({
94+
localize: this.localize
95+
});
96+
}
97+
else {
98+
var pluginConfig = config['vs/nls'] || {};
99+
var language = pluginConfig.availableLanguages ? findLanguageForModule(pluginConfig.availableLanguages, name) : null;
100+
var suffix = '.nls';
101+
if (language !== null && language !== NLSPlugin.DEFAULT_TAG) {
102+
suffix = suffix + '.' + language;
103+
}
104+
req([name + suffix], function (messages) {
105+
if (Array.isArray(messages)) {
106+
messages.localize = createScopedLocalize(messages, _this._env);
107+
}
108+
else {
109+
messages.localize = createScopedLocalize(messages[name], _this._env);
110+
}
111+
load(messages);
112+
});
113+
}
114+
};
115+
return NLSPlugin;
116+
}());
117+
NLSPlugin.DEFAULT_TAG = 'i-default';
118+
NLSLoaderPlugin.NLSPlugin = NLSPlugin;
119+
function init() {
120+
define('vs/nls', new NLSPlugin(Environment.detect()));
121+
}
122+
NLSLoaderPlugin.init = init;
123+
if (typeof doNotInitLoader === 'undefined') {
124+
init();
125+
}
120126
})(NLSLoaderPlugin || (NLSLoaderPlugin = {}));

0 commit comments

Comments
 (0)