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

easygettext

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easygettext - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

40

dist/extract.js
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
Object.defineProperty(exports, "__esModule", {

@@ -8,6 +12,2 @@ value: true

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _cheerio = require('cheerio');

@@ -60,3 +60,3 @@

var TranslationReference = exports.TranslationReference = function () {
var TranslationReference = exports.TranslationReference = (function () {
function TranslationReference(filename, content, charPosition) {

@@ -83,8 +83,6 @@ _classCallCheck(this, TranslationReference);

return TranslationReference;
}();
})();
var NodeTranslationInfo = exports.NodeTranslationInfo = function () {
function NodeTranslationInfo(node, text, reference) {
var attributes = arguments.length <= 3 || arguments[3] === undefined ? constants.DEFAULT_ATTRIBUTES : arguments[3];
var NodeTranslationInfo = exports.NodeTranslationInfo = (function () {
function NodeTranslationInfo(node, text, reference, attributes) {
_classCallCheck(this, NodeTranslationInfo);

@@ -116,5 +114,5 @@

return NodeTranslationInfo;
}();
})();
var Extractor = exports.Extractor = function () {
var Extractor = exports.Extractor = (function () {
function Extractor(options) {

@@ -142,6 +140,8 @@ var _this = this;

this.items = {};
this.filterRegexps = constants.DEFAULT_ATTRIBUTES.map(function (attribute) {
this.filterRegexps = this.options.attributes.map(function (attribute) {
var startOrEndQuotes = '(?:\\&quot;|[\\\'"])'; // matches simple / double / HTML quotes
var spacesOrPipeChar = '\\s*\\|\\s*'; // matches the pipe string of the filter
var start = _this.options.startDelim.replace(ESCAPE_REGEX, '\\$&');
var end = _this.options.endDelim.replace(ESCAPE_REGEX, '\\$&');
return new RegExp(start + '.*[\\\'"](.*)[\\\'"]\\s*\\|\\s*' + attribute + '.*' + end);
return new RegExp(start + '.*' + startOrEndQuotes + '(.*)' + startOrEndQuotes + spacesOrPipeChar + attribute + '.*' + end);
});

@@ -254,3 +254,3 @@ }

return $('*').map(function (_i, el) {
return $('*').map((function (_i, el) {
var _this2 = this;

@@ -282,5 +282,5 @@

if (matches.length !== 0) {
var _text = matches[0][1].trim();
if (_text.length !== 0) {
tokensFromFilters.push(new NodeTranslationInfo(node, _text, reference, _this2.options.attributes));
var text = matches[0][1].trim();
if (text.length !== 0) {
tokensFromFilters.push(new NodeTranslationInfo(node, text, reference, _this2.options.attributes));
}

@@ -293,3 +293,3 @@ }

}
}.bind(this)).get().filter(function (x) {
}).bind(this)).get().filter(function (x) {
return x !== undefined;

@@ -308,3 +308,3 @@ });

return Extractor;
}();
})();
//# sourceMappingURL=extract.js.map

@@ -123,4 +123,8 @@ 'use strict';

(0, _chai.expect)(data2[0].text).to.equal('Hola, hola');
var data3 = extractor._extractTranslationData(fixtures.FILENAME_0, fixtures.HTML3_FILTER3);
(0, _chai.expect)(data3.length).to.equal(1);
(0, _chai.expect)(data3[0].text).to.equal('So long, my dear');
});
});
//# sourceMappingURL=extract.spec.js.map

@@ -21,2 +21,3 @@ 'use strict';

var HTML3_FILTER2 = exports.HTML3_FILTER2 = "<h2 tooltip=\"{{ a || 'Hola, hola'|i18n }}\">StufStuff</h2>";
var HTML3_FILTER3 = exports.HTML3_FILTER3 = "<h2 attr=\"{{ &quot;So long, my dear' |i18n }}\">Martha</h2>";

@@ -23,0 +24,0 @@ var HTML4_TAG0 = exports.HTML4_TAG0 = '<translate>Duck</translate>';

{
"name": "easygettext",
"version": "1.2.0",
"version": "1.2.1",
"description": "Simple tools to extract gettext strings",

@@ -5,0 +5,0 @@ "main": "dist/index",

@@ -50,3 +50,3 @@ import cheerio from 'cheerio';

export class NodeTranslationInfo {
constructor(node, text, reference, attributes = constants.DEFAULT_ATTRIBUTES) {
constructor(node, text, reference, attributes) {
this.text = text;

@@ -92,6 +92,8 @@ this.reference = reference;

this.items = {};
this.filterRegexps = constants.DEFAULT_ATTRIBUTES.map((attribute) => {
this.filterRegexps = this.options.attributes.map((attribute) => {
const startOrEndQuotes = `(?:\\&quot;|[\\'"])` // matches simple / double / HTML quotes
const spacesOrPipeChar = `\\s*\\|\\s*` // matches the pipe string of the filter
const start = this.options.startDelim.replace(ESCAPE_REGEX, '\\$&');
const end = this.options.endDelim.replace(ESCAPE_REGEX, '\\$&');
return new RegExp(`${start}.*[\\'"](.*)[\\'"]\\s*\\|\\s*${attribute}.*${end}`);
return new RegExp(`${start}.*${startOrEndQuotes}(.*)${startOrEndQuotes}${spacesOrPipeChar}${attribute}.*${end}`);
});

@@ -98,0 +100,0 @@ }

@@ -115,3 +115,7 @@ import {Extractor} from './extract.js';

expect(data2[0].text).to.equal('Hola, hola');
const data3 = extractor._extractTranslationData(fixtures.FILENAME_0, fixtures.HTML3_FILTER3);
expect(data3.length).to.equal(1);
expect(data3[0].text).to.equal('So long, my dear');
});
});

@@ -19,2 +19,3 @@ export const FILENAME_0 = 'foo.htm';

export const HTML3_FILTER2 = "<h2 tooltip=\"{{ a || 'Hola, hola'|i18n }}\">StufStuff</h2>";
export const HTML3_FILTER3 = "<h2 attr=\"{{ &quot;So long, my dear' |i18n }}\">Martha</h2>";

@@ -21,0 +22,0 @@ export const HTML4_TAG0 = '<translate>Duck</translate>';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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