New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-parser - npm Package Compare versions

Comparing version 1.0.0-beta6 to 1.0.0-beta7

6

CHANGELOG.md
# Changelog
## 1.0.0-beta2 - latest
## 1.0.0-beta7 - latest
- See [release](https://github.com/i18next/i18next-parser/releases/tag/1.0.0-beta7)
## 1.0.0-beta2
- See [release](https://github.com/i18next/i18next-parser/releases/tag/1.0.0-beta2)

@@ -6,0 +10,0 @@

@@ -37,2 +37,8 @@ 'use strict';Object.defineProperty(exports, "__esModule", { 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 _helpers = require('./helpers');

_this.options = _extends({}, _this.defaults, options);
if (_this.options.keySeparator === false) {
_this.options.keySeparator = '__!NO_KEY_SEPARATOR!__';
}
if (_this.options.namespaceSeparator === false) {
_this.options.namespaceSeparator = '__!NO_NAMESPACE_SEPARATOR!__';
}
_this.entries = [];

@@ -39,0 +45,0 @@

@@ -43,4 +43,8 @@ 'use strict';Object.defineProperty(exports, "__esModule", { 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 _htmlLexer = require('./html-lexer');var _htmlLexer2 = _interopRequireDefault(_htmlLexer);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;}var

var key = attrs.keys;
if (matches[2] && !attrs.options.defaultValue) {
attrs.options.defaultValue = matches[2].trim();
}
if (key) {
attrs.options.defaultValue = attrs.options.defaultValue || matches[2].trim();
this.keys.push(_extends({}, attrs.options, { key: key }));

@@ -47,0 +51,0 @@ }

@@ -57,1 +57,9 @@ # Contribute

I will not maintain the old version but will welcome bug fixes as PRs.
## Deploy
- `yarn watch`
- update `package.json` version
- create commit and add version tag
- `npm pulish --tag next` (skip next tag if not in beta)
- create a github release

2

package.json

@@ -5,3 +5,3 @@ {

"name": "i18next-parser",
"version": "1.0.0-beta6",
"version": "1.0.0-beta7",
"license": "MIT",

@@ -8,0 +8,0 @@ "main": "src/index.js",

@@ -74,24 +74,25 @@ # i18next Parser [![Build Status](https://travis-ci.org/i18next/i18next-parser.svg?branch=master)](https://travis-ci.org/i18next/i18next-parser)

Option | Description | Default
Option | Description | Default
---------------------- | ----------------------------------------------------- | ---
**contextSeparator** | Key separator used in your translation keys | `_`
**createOldCatalogs** | Save the \_old files | `true`
**defaultNamespace** | Default namespace used in your i18next config | `translation`
**defaultValue** | Default value to give to empty keys | `''`
**extension** | Edit the extension of the locale files | `.json`
**filename** | Edit the filename of the locale files | `'$NAMESPACE'`
**indentation** | Indentation of the catalog files | `2`
**keepRemoved** | Keep keys from the catalog that are no longer in code | `false`
**keySeparator** | Key separator used in your translation keys | `.`
**lexers** | See below for details | `{}`
**lineEnding** | Control the line ending. See options at [eol](https://github.com/ryanve/eol) | `auto`
**locales** | An array of the locales in your applications | `['en','fr']`
**namespaceSeparator** | Namespace separator used in your translation keys | `:`
**output** | Where to write the locale files relative to the base | `locales`
**reactNamespace** | For react file, extract the [defaultNamespace](https://react.i18next.com/components/translate-hoc.html) | `false` (`true` for `.jsx` files)
**sort** | Whether or not to sort the catalog | `false`
**contextSeparator** | Key separator used in your translation keys | `_`
**createOldCatalogs** | Save the \_old files | `true`
**defaultNamespace** | Default namespace used in your i18next config | `translation`
**defaultValue** | Default value to give to empty keys | `''`
**extension** <sup>1<sup>| Extenstion of the catalogs | `.json`
**filename** <sup>1<sup>| Filename of the catalogs | `'$NAMESPACE'`
**indentation** | Indentation of the catalog files | `2`
**keepRemoved** | Keep keys from the catalog that are no longer in code | `false`
**keySeparator** <sup>2<sup>| Key separator used in your translation keys | `.`
**lexers** | See below for details | `{}`
**lineEnding** | Control the line ending. See options at [eol](https://github.com/ryanve/eol) | `auto`
**locales** | An array of the locales in your applications | `['en','fr']`
**namespaceSeparator** <sup>2<sup>| Namespace separator used in your translation keys | `:`
**output** | Where to write the locale files relative to the base | `locales`
**reactNamespace** <sup>3<sup>| For react file, extract the [defaultNamespace](https://react.i18next.com/components/translate-hoc.html) | `false`
**sort** | Whether or not to sort the catalog | `false`
### Catalog filenames
1. Both `filename` and `extension` options support injection of `$LOCALE` and `$NAMESPACE` variables. The file output is JSON by default, if you want YAML, the `extension` must end with `yml`.
2. If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
3. If the file being parsed has a `.jsx` extension, this option is ignored and the namespace is being extracted.
Both `filename` and `extension` options support injection of `$LOCALE` and `$NAMESPACE` variables.

@@ -102,3 +103,3 @@ ### Lexers

```
```js
{

@@ -123,3 +124,3 @@ lexers: {

```
```js
{

@@ -133,3 +134,3 @@ lexers: {

],
...
// ...
}

@@ -136,0 +137,0 @@ }

@@ -37,2 +37,8 @@ import { dotPathToHash, mergeHashes, populateHash } from './helpers'

this.options = { ...this.defaults, ...options }
if (this.options.keySeparator === false) {
this.options.keySeparator = '__!NO_KEY_SEPARATOR!__'
}
if (this.options.namespaceSeparator === false) {
this.options.namespaceSeparator = '__!NO_NAMESPACE_SEPARATOR!__'
}
this.entries = []

@@ -39,0 +45,0 @@

@@ -43,4 +43,8 @@ import HTMLLexer from './html-lexer'

const key = attrs.keys
if (matches[2] && !attrs.options.defaultValue) {
attrs.options.defaultValue = matches[2].trim()
}
if (key) {
attrs.options.defaultValue = attrs.options.defaultValue || matches[2].trim()
this.keys.push({ ...attrs.options, key })

@@ -47,0 +51,0 @@ }

@@ -17,3 +17,3 @@ import { assert } from 'chai'

describe('Trans', () => {
it('extracts keys from i18nKey attributes', (done) => {
it('extracts keys from i18nKey attributes from closing tags', (done) => {
const Lexer = new JsxLexer()

@@ -26,3 +26,12 @@ const content = '<Trans i18nKey="first" count={count}>Yo</Trans>'

})
it('extracts keys from i18nKey attributes from self-closing tags', (done) => {
const Lexer = new JsxLexer()
const content = '<Trans i18nKey="first" count={count} />'
assert.deepEqual(Lexer.extractTrans(content), [
{ key: 'first' }
])
done()
})
})
})

@@ -188,3 +188,4 @@ import { assert } from 'chai'

},
fourth: ''
fourth: '',
fifth: ''
}

@@ -511,2 +512,26 @@

it('handles disabling namespace and key separators', (done) => {
let result
const i18nextParser = new i18nTransform({
namespaceSeparator: false,
keySeparator: false
})
const fakeFile = new Vinyl({
contents: Buffer.from("asd t('Status: loading...')"),
path: 'file.js'
})
i18nextParser.on('data', file => {
if (file.relative.endsWith(enLibraryPath)) {
result = JSON.parse(file.contents)
}
})
i18nextParser.once('end', () => {
assert.deepEqual(result, { 'Status: loading...': '' })
done()
})
i18nextParser.end(fakeFile)
})
it('supports a defaultValue', (done) => {

@@ -552,3 +577,4 @@ let result

},
fourth: ''
fourth: '',
fifth: ''
}

@@ -555,0 +581,0 @@

import React from 'react'
import { translate } from 'react-i18next'
import { translate, Trans, Interpolate } from 'react-i18next'

@@ -14,2 +14,3 @@ class Test extends React.Component {

</Trans>
<Trans i18nKey="fifth" count={count} />
</div>

@@ -16,0 +17,0 @@ )

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