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.1.1 to 1.2.0

2

dist/constants.js

@@ -6,3 +6,3 @@ 'use strict';

});
var DEFAULT_ATTRIBUTES = exports.DEFAULT_ATTRIBUTES = ['translate', 'i18n'];
var DEFAULT_ATTRIBUTES = exports.DEFAULT_ATTRIBUTES = ['i18n', 'translate'];

@@ -9,0 +9,0 @@ var ATTRIBUTE_COMMENT = exports.ATTRIBUTE_COMMENT = 'comment';

@@ -16,9 +16,16 @@ #!/usr/bin/env node

var _constants = require('./constants.js');
var constants = _interopRequireWildcard(_constants);
var _extract = require('./extract.js');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var PROGRAM_NAME = 'easygettext';
/* eslint no-console:0 */
var PROGRAM_NAME = 'easygettext';
var ALLOWED_EXTENSIONS = ['html', 'htm', 'jade'];

@@ -31,10 +38,27 @@

var outputFile = argv.output || null;
// Allow to pass extra attributes, e.g. gettext-extract --attribute v-translate --attribute v-i18n
var extraAttribute = argv.attribute || false;
if (!quietMode && (!files || files.length === 0)) {
console.log('Usage:\n\tgettext-extract [--output OUTFILE] <FILES>');
console.log('Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--output OUTFILE] <FILES>');
process.exit(1);
}
var attributes = constants.DEFAULT_ATTRIBUTES.slice();
if (extraAttribute) {
if (typeof extraAttribute === 'string') {
// Only one extra attribute was passed.
attributes.push(extraAttribute);
} else {
// Multiple extra attributes were passed.
attributes = attributes.concat(extraAttribute);
}
}
// Extract strings
var extractor = new _extract.Extractor({ lineNumbers: true });
var extractor = new _extract.Extractor({
lineNumbers: true,
attributes: attributes
});
files.forEach(function (filename) {

@@ -41,0 +65,0 @@ var file = filename;

'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", {

@@ -12,2 +8,6 @@ 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,5 +83,5 @@ _classCallCheck(this, TranslationReference);

return TranslationReference;
})();
}();
var NodeTranslationInfo = exports.NodeTranslationInfo = (function () {
var NodeTranslationInfo = exports.NodeTranslationInfo = function () {
function NodeTranslationInfo(node, text, reference) {

@@ -116,5 +116,5 @@ var attributes = arguments.length <= 3 || arguments[3] === undefined ? constants.DEFAULT_ATTRIBUTES : arguments[3];

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

@@ -253,3 +253,3 @@ var _this = this;

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

@@ -281,5 +281,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));
}

@@ -292,3 +292,3 @@ }

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

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

return Extractor;
})();
}();
//# sourceMappingURL=extract.js.map
{
"name": "easygettext",
"version": "1.1.1",
"version": "1.2.0",
"description": "Simple tools to extract gettext strings",

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

@@ -47,3 +47,3 @@ # easygettext

```
```html
<div translate>Hello World</div>

@@ -61,2 +61,10 @@ <div translate translate-context="According to...">Hello World</div>

You can also provide your own master tokens:
```
gettext-extract --attribute v-translate --output dictionary.pot foo.html bar.jade
gettext-extract --attribute v-translate --attribute v-i18n --output dictionary.pot foo.html bar.jade
```
##### gettext-compile

@@ -74,3 +82,3 @@

```
```javascript
npm test

@@ -81,6 +89,20 @@ ```

```
```javascript
npm run cover
```
### Testing the CLI
Run:
```javascript
npm run prepublish
```
Then run `extract-cli.js`:
```
./dist/extract-cli.js --attribute v-translate --attribute v-i18n ~/output.html
```
### Credits

@@ -87,0 +109,0 @@

export const DEFAULT_ATTRIBUTES = [
'i18n',
'translate',
'i18n',
];

@@ -5,0 +5,0 @@

@@ -9,2 +9,3 @@ #!/usr/bin/env node

import * as constants from './constants.js';
import {Extractor} from './extract.js';

@@ -20,11 +21,25 @@

const outputFile = argv.output || null;
// Allow to pass extra attributes, e.g. gettext-extract --attribute v-translate --attribute v-i18n
const extraAttribute = argv.attribute || false;
if (!quietMode && (!files || files.length === 0)) {
console.log('Usage:\n\tgettext-extract [--output OUTFILE] <FILES>');
console.log('Usage:\n\tgettext-extract [--attribute EXTRA-ATTRIBUTE] [--output OUTFILE] <FILES>');
process.exit(1);
}
let attributes = constants.DEFAULT_ATTRIBUTES.slice()
if (extraAttribute) {
if (typeof extraAttribute === 'string') { // Only one extra attribute was passed.
attributes.push(extraAttribute)
} else { // Multiple extra attributes were passed.
attributes = attributes.concat(extraAttribute)
}
}
// Extract strings
const extractor = new Extractor({lineNumbers: true});
const extractor = new Extractor({
lineNumbers: true,
attributes: attributes
});
files.forEach(function(filename) {

@@ -31,0 +46,0 @@ let file = filename;

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