mirror of
https://github.com/Microsoft/vscode
synced 2024-10-04 02:14:06 +00:00
[css] have compiled vscode-nls shim
This commit is contained in:
parent
9de8a85408
commit
57b0384a1a
|
@ -1,46 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export interface Options {
|
||||
locale?: string;
|
||||
cacheLanguageResolution?: boolean;
|
||||
}
|
||||
export interface LocalizeInfo {
|
||||
key: string;
|
||||
comment: string[];
|
||||
}
|
||||
export interface LocalizeFunc {
|
||||
(info: LocalizeInfo, message: string, ...args: any[]): string;
|
||||
(key: string, message: string, ...args: any[]): string;
|
||||
}
|
||||
export interface LoadFunc {
|
||||
(file?: string): LocalizeFunc;
|
||||
}
|
||||
|
||||
function format(message: string, args: any[]): string {
|
||||
let result: string;
|
||||
|
||||
if (args.length === 0) {
|
||||
result = message;
|
||||
} else {
|
||||
result = message.replace(/\{(\d+)\}/g, (match, rest) => {
|
||||
let index = rest[0];
|
||||
return typeof args[index] !== 'undefined' ? args[index] : match;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function localize(_key: string | LocalizeInfo, message: string, ...args: any[]): string {
|
||||
return format(message, args);
|
||||
}
|
||||
|
||||
export function loadMessageBundle(_file?: string): LocalizeFunc {
|
||||
return localize;
|
||||
}
|
||||
|
||||
export function config(_opt?: Options | string): LoadFunc {
|
||||
return loadMessageBundle;
|
||||
}
|
|
@ -9,12 +9,6 @@
|
|||
|
||||
const withDefaults = require('../shared.webpack.config');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const vscodeNlsReplacement = new webpack.NormalModuleReplacementPlugin(
|
||||
/vscode\-nls[\\/]lib[\\/]main\.js/,
|
||||
path.join(__dirname, 'client/out/browser/vscodeNlsShim.js')
|
||||
);
|
||||
|
||||
const clientConfig = withDefaults({
|
||||
target: 'webworker',
|
||||
|
@ -28,9 +22,13 @@ const clientConfig = withDefaults({
|
|||
},
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'vscode-nls': path.resolve(__dirname, 'polyfills/vscode-nls.js')
|
||||
}
|
||||
}
|
||||
});
|
||||
clientConfig.plugins[1] = vscodeNlsReplacement; // replace nls bundler
|
||||
clientConfig.module.rules[0].use.shift(); // remove nls loader
|
||||
|
||||
module.exports = clientConfig;
|
||||
|
|
79
extensions/css-language-features/polyfills/vscode-nls.js
Normal file
79
extensions/css-language-features/polyfills/vscode-nls.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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;
|
|
@ -9,12 +9,6 @@
|
|||
|
||||
const withDefaults = require('../../shared.webpack.config');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
|
||||
const vscodeNlsReplacement = new webpack.NormalModuleReplacementPlugin(
|
||||
/vscode\-nls[\\/]lib[\\/]main\.js/,
|
||||
path.join(__dirname, '../client/out/browser/vscodeNlsShim.js')
|
||||
);
|
||||
|
||||
const serverConfig = withDefaults({
|
||||
target: 'webworker',
|
||||
|
@ -29,9 +23,13 @@ const serverConfig = withDefaults({
|
|||
},
|
||||
performance: {
|
||||
hints: false
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'vscode-nls': path.resolve(__dirname, '../polyfills/vscode-nls.js')
|
||||
}
|
||||
}
|
||||
});
|
||||
serverConfig.plugins[1] = vscodeNlsReplacement; // replace nls bundler
|
||||
serverConfig.module.rules[0].use.shift(); // remove nls loader
|
||||
|
||||
module.exports = serverConfig;
|
||||
|
|
Loading…
Reference in a new issue