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

i18next-parser

Package Overview
Dependencies
Maintainers
1
Versions
144
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 0.1.6 to 0.1.7

4

bin/cli.js

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

program
.version('0.1.6')
.version('0.1.7')
.option('-r, --recursive' , 'Parse sub directories')

@@ -119,3 +119,3 @@ .option('-p, --parser <string>' , 'A custom regex to use to parse your code')

}))
.pipe(parser.on('parsing', function(path) { console.log("[parse] ".green + path) }))
.pipe(parser.on('reading', function(path) { console.log("[parse] ".green + path) }))
.pipe(through( { objectMode: true }, function (file, encoding, done) {

@@ -122,0 +122,0 @@

@@ -97,3 +97,3 @@ var gutil = require('gulp-util');

this.emit( 'parsing', file.path );
this.emit( 'reading', file.path );

@@ -193,2 +193,5 @@ while ( matches = regex.exec( fileContent ) ) {

this.emit( 'writing', namespacePath );
this.emit( 'writing', namespaceOldPath );
self.push( mergedTranslationsFile );

@@ -195,0 +198,0 @@ self.push( mergedOldTranslationsFile );

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

"name": "i18next-parser",
"version": "0.1.6",
"version": "0.1.7",
"bin": {

@@ -8,0 +8,0 @@ "i18next": "./bin/cli.js"

@@ -30,10 +30,21 @@ # i18next Parser

---
## CLI Usage
---
`i18next /path/to/file/or/dir [-orpfnl]`
- **-o, --output <directory>**: Where to write the locale files.
- **-r, --recursive**: Is --output is a directory, parses files in sub directories.
- **-f, --function <list>**: Function names to parse. Defaults to `t`
- **-p, --parser <string>**: A custom regex for the parser to use.
- **-n, --namespace <string>**: Default namespace in i18next. Defaults to `translation`
- **-l, --locales <list>**: The locales in your applications. Defaults to `en,fr`
---
## Gulp Usage
[Gulp](http://gulpjs.com/) defines itself as the streaming build system. Put simply, it is like Grunt, but performant and elegant.
```javascript

@@ -56,17 +67,12 @@ var i18next = require('i18next-parser');

---
**Events**
The transform emit a `reading` event for each file it parses:
`.pipe( i18next().on('reading', function(path) { }) )`
## CLI Usage
The transform emit a `writing` event for each file it passes to the stream:
`i18next /path/to/file/or/dir [-orpfnl]`
`.pipe( i18next().on('reading', function(path) { }) )`
- **-o, --output <directory>**: Where to write the locale files.
- **-r, --recursive**: Is --output is a directory, parses files in sub directories.
- **-f, --function <list>**: Function names to parse. Defaults to `t`
- **-p, --parser <string>**: A custom regex for the parser to use.
- **-n, --namespace <string>**: Default namespace in i18next. Defaults to `translation`
- **-l, --locales <list>**: The locales in your applications. Defaults to `en,fr`
---

@@ -76,41 +82,12 @@

**Change the locales (cli and gulp)**
Command line:
**Parse single file or directory**
`i18next /path/to/file/or/dir -l en,de,sp`
`i18next /path/to/file/or/dir`
Gulp:
It will create the following files in the directory from which you run the command:
`.pipe(i18next({locales: ['en', 'de', 'sp']}))`
```
locales/en/translation.json
locales/en/namespace1.json
locales/en/translation_old.json
locales/en/namespace1_old.json
locales/fr/translation.json
locales/fr/namespace1.json
locales/fr/translation_old.json
locales/fr/namespace1_old.json
...
```
**Change the output directory**
`i18next /path/to/file/or/dir -o /output/directory`
It will create the file in the specified folder:
```
/output/directory/en/translation.json
...
```
**Change the locales**
`i18next /path/to/file/or/dir -l en,de,sp`
This will create a directory per locale in the output folder:

@@ -126,6 +103,12 @@

**Change the default namespace**
**Change the default namespace (cli and gulp)**
Command line:
`i18next /path/to/file/or/dir -n my_default_namespace`
Gulp:
`.pipe(i18next({namespace: 'my_default_namespace'}))`
This will add all the translation from the default namespace in the following file:

@@ -140,14 +123,12 @@

**Filter files and folders**
**Change the translation functions (cli and gulp)**
`i18next /path/to/file/or/dir -filterFolder *.hbs,*.js -filterFolder !.git`
Command line:
In recursive mode, it will parse `*.hbs` and `*.js` files and skip `.git` folder. This options is passed to readdirp. To learn more, read [their documentation](https://github.com/thlorenz/readdirp#filters).
`i18next /path/to/file/or/dir -f __,_e`
Gulp:
`.pipe(i18next({functions: ['__', '_e']}))`
**Change the translation functions**
`i18next /path/to/file/or/dir -f __,_e`
This will parse any of the following function calls in your code and extract the key:

@@ -172,6 +153,12 @@

**Change the regex**
**Change the regex (cli and gulp)**
Command line:
`i18next /path/to/file/or/dir -r "(.*)"`
Gulp:
`.pipe(i18next({regex: '(.*)'}))`
You must pass the regex as a string. That means that you will have to properly escape it.

@@ -182,1 +169,22 @@

`/[^a-zA-Z0-9](?:(?:t)|(?:i18n\.t))(?:\(|\s)\s*(?:(?:'((?:(?:\\')?[^']+)+[^\\])')|(?:"((?:(?:\\")?[^"]+)+[^\\])"))/g`
**Change the output directory (cli)**
`i18next /path/to/file/or/dir -o /output/directory`
It will create the file in the specified folder:
```
/output/directory/en/translation.json
...
```
**Filter files and folders (cli)**
`i18next /path/to/file/or/dir -filterFolder *.hbs,*.js -filterFolder !.git`
In recursive mode, it will parse `*.hbs` and `*.js` files and skip `.git` folder. This options is passed to readdirp. To learn more, read [their documentation](https://github.com/thlorenz/readdirp#filters).
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