Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-nls

Package Overview
Dependencies
Maintainers
9
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-nls - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0-next.1

16

lib/main.d.ts

@@ -16,3 +16,17 @@ export interface Options {

}
export declare enum ExtensionKind {
prePackaged = "prePackaged",
marketPlace = "marketPlace",
}
export interface LocalizeInfo {
key: string;
comment: string[];
}
export declare namespace LocalizeInfo {
function is(value: any): value is LocalizeInfo;
}
export declare type KeyInfo = string | LocalizeInfo;
export declare function loadMessageBundle(file?: string): LocalizeFunc;
export declare function config(opt?: Options | string): LoadFunc;
export declare function config(opt?: Options): LoadFunc;
export declare function config(opt?: string): LoadFunc;
export declare function config(opt: string, kind: ExtensionKind, root: string, outDir: string): LoadFunc;

@@ -6,7 +6,17 @@ /* --------------------------------------------------------------------------------------------

'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var fs = require("fs");
var ExtensionKind;
(function (ExtensionKind) {
ExtensionKind["prePackaged"] = "prePackaged";
ExtensionKind["marketPlace"] = "marketPlace";
})(ExtensionKind = exports.ExtensionKind || (exports.ExtensionKind = {}));
var _options = { locale: undefined, cacheLanguageResolution: true };
var _isPseudo = false;
var _resolvedLanguage = null;
var _extensionKind = undefined;
var _root = undefined;
var _outDir = undefined;
var _resolvedLanguage = undefined;
var _resolvedCacheLocation = undefined;
var toString = Object.prototype.toString;

@@ -25,2 +35,13 @@ function isDefined(value) {

}
function supportsLanguagePack() {
if (_extensionKind === ExtensionKind.prePackaged) {
return _options._resolvedLanguagePackExtensionLocation !== undefined && _root !== undefined && _outDir !== undefined;
}
else if (_extensionKind === ExtensionKind.marketPlace) {
return _options._cacheRoot !== undefined && _root !== undefined && _outDir !== undefined;
}
else {
return false;
}
}
function format(message, args) {

@@ -113,2 +134,30 @@ var result;

}
var LocalizeInfo;
(function (LocalizeInfo) {
function is(value) {
var candidate = value;
return candidate && isDefined(candidate.key) && isDefined(candidate.comment);
}
LocalizeInfo.is = is;
})(LocalizeInfo = exports.LocalizeInfo || (exports.LocalizeInfo = {}));
function mkdir(directory) {
try {
fs.mkdirSync(directory);
}
catch (err) {
if (err.code === 'EEXIST') {
return;
}
else if (err.code === 'ENOENT') {
var parent = path.dirname(directory);
if (parent !== directory) {
mkdir(parent);
fs.mkdir(directory);
}
}
else {
throw err;
}
}
}
function loadMessageBundle(file) {

@@ -119,3 +168,46 @@ if (!file) {

else {
var resolvedFile = resolveLanguage(file);
var resolvedFile = void 0;
// We have a language pack test locale
if (_options.locale === 'lptest' && supportsLanguagePack()) {
if (_resolvedCacheLocation === undefined) {
try {
var packageJson = require(path.join(_root, 'package.json'));
var extensionName = packageJson.name;
if (extensionName) {
var cacheLocation = path.join(_options._resolvedLanguagePackExtensionLocation, extensionName);
if (fs.existsSync(cacheLocation)) {
_resolvedCacheLocation = cacheLocation;
}
else {
mkdir(cacheLocation);
var metaData = require(path.join(_root, _outDir, 'nls.metadata.json'));
for (var file_1 in metaData.content) {
var entry = metaData.content[file_1];
var cacheFilePath = path.join(cacheLocation, _outDir, file_1 + '.json');
mkdir(path.dirname(cacheFilePath));
var content = [];
for (var message in entry.messages) {
content.push('\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D');
}
fs.writeFileSync(cacheFilePath, content, 'utf8');
}
_resolvedCacheLocation = cacheLocation;
}
}
}
catch (err) {
_resolvedCacheLocation = null;
// Fall through;
}
}
if (isString(_resolvedCacheLocation)) {
resolvedFile = path.join(_resolvedCacheLocation, file.substr(_root.length + 1));
}
}
else {
resolvedFile = resolveLanguage(file);
}
if (!resolvedFile) {
return localize;
}
try {

@@ -143,3 +235,3 @@ var json = require(resolvedFile);

exports.loadMessageBundle = loadMessageBundle;
function config(opt) {
function config(opt, kind, root, outDir) {
var options;

@@ -157,6 +249,11 @@ if (isString(opt)) {

}
if (kind && root && path.isAbsolute(root)) {
_extensionKind = kind;
_root = root;
_outDir = outDir;
}
if (options) {
if (isString(options.locale)) {
_options.locale = options.locale.toLowerCase();
_resolvedLanguage = null;
_resolvedLanguage = undefined;
}

@@ -163,0 +260,0 @@ if (isBoolean(options.cacheLanguageResolution)) {

4

package.json
{
"name": "vscode-nls",
"version": "2.0.2",
"version": "3.0.0-next.1",
"description": "NPM module to externalize and localize VSCode extensions",

@@ -28,2 +28,2 @@ "author": "Microsoft Corporation",

}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc