Skip to content

Commit

Permalink
Merge pull request #508 from i18next/6.0.0
Browse files Browse the repository at this point in the history
6.0.0
  • Loading branch information
karellm authored Mar 13, 2022
2 parents 17c5c85 + a019101 commit c04e7ed
Show file tree
Hide file tree
Showing 40 changed files with 278 additions and 222 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"presets": [
"@babel/preset-env"
[
"@babel/preset-env",
{
"modules": false
}
]
],
"plugins": [
"@babel/transform-runtime",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 13.x, 14.x, 15.x, 16.x]
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
export default {
'*.{js,css,md}': 'yarn prettify',
}
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": true
}
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"--require", "@babel/register",
"--require", "@babel/polyfill",
"--plugins", "@babel/plugin-transform-runtime",
"${workspaceFolder}/test/**/*.test.js"
"${workspaceFolder}/test/**/*.test.js",
"${workspaceFolder}/test/*.test.js"
],
"runtimeArgs": [
"--nolazy"
Expand Down
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,19 @@ npm install --save-dev i18next-parser
[Gulp](http://gulpjs.com/) defines itself as the streaming build system. Put simply, it is like Grunt, but performant and elegant.

```javascript
const i18nextParser = require('i18next-parser').gulp;

gulp.task('i18next', function() {
gulp.src('app/**')
.pipe(new i18nextParser({
locales: ['en', 'de'],
output: 'locales/$LOCALE/$NAMESPACE.json'
}))
.pipe(gulp.dest('./'));
});
import { gulp as i18nextParser } from 'i18next-parser'

gulp.task('i18next', function () {
gulp
.src('app/**')
.pipe(
new i18nextParser({
locales: ['en', 'de'],
output: 'locales/$LOCALE/$NAMESPACE.json',
})
)
.pipe(gulp.dest('./'))
})
```

**IMPORTANT**: `output` is required to know where to read the catalog from. You might think that `gulp.dest()` is enough though it does not inform the transform where to read the existing catalog from.
Expand All @@ -91,8 +94,8 @@ npm install --save-dev i18next-parser
[Broccoli.js](https://github.com/broccolijs/broccoli) defines itself as a fast, reliable asset pipeline, supporting constant-time rebuilds and compact build definitions.

```javascript
const Funnel = require('broccoli-funnel')
const i18nextParser = require('i18next-parser').broccoli
import Funnel from 'broccoli-funnel'
import { broccoli as i18nextParser} from 'i18next-parser')

const appRoot = 'broccoli'

Expand All @@ -105,7 +108,7 @@ i18n = new i18nextParser([i18n], {
output: 'broccoli/locales/$LOCALE/$NAMESPACE.json'
})

module.exports = i18n
export default i18n
```

## Options
Expand All @@ -115,7 +118,7 @@ Using a config file gives you fine-grained control over how i18next-parser treat
```js
// i18next-parser.config.js

module.exports = {
export default {
contextSeparator: '_',
// Key separator used in your translation keys

Expand Down Expand Up @@ -153,7 +156,7 @@ module.exports = {
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],

default: ['JavascriptLexer']
default: ['JavascriptLexer'],
},

lineEnding: 'auto',
Expand Down Expand Up @@ -217,8 +220,8 @@ module.exports = {
// for that key across locales are reset to the default value, and existing translations are moved to
// the `_old` file.

i18nextOptions: null
// If you wish to customize options in internally used i18next instance, you can define an object with any
i18nextOptions: null,
// If you wish to customize options in internally used i18next instance, you can define an object with any
// configuration property supported by i18next (https://www.i18next.com/overview/configuration-options).
// { compatibilityJSON: 'v3' } can be used to generate v3 compatible plurals.
}
Expand Down Expand Up @@ -288,8 +291,8 @@ Typescript is supported via Javascript and Jsx lexers. If you are using Javascri
handlebars: [
{
lexer: 'HandlebarsLexer',
functions: ['t'] // Array of functions to match
}
functions: ['t'], // Array of functions to match
},
]
}
```
Expand All @@ -312,7 +315,7 @@ Typescript is supported via Javascript and Jsx lexers. If you are using Javascri
You can provide function instead of string as a custom lexer.

```js
const CustomJsLexer = require('./CustomJsLexer');
import CustomJsLexer from './CustomJsLexer';

// ...
{
Expand Down Expand Up @@ -369,7 +372,6 @@ Here is a list of the warnings:
- **Found same keys with different values**: if you use different default values for the same key, you'll get this error. For example, having `t('key', {defaultValue: 'foo'})` and `t('key', {defaultValue: bar'})`. The parser will select the latest one.
- **Found translation key already mapped to a map or parent of new key already mapped to a string**: happens in this kind of situation: `t('parent', {defaultValue: 'foo'})` and `t('parent.child', {defaultValue: 'bar'})`. `parent` is both a translation and an object for `child`.


## Contribute

Any contribution is welcome. Please [read the guidelines](docs/development.md) first.
Expand Down
Loading

0 comments on commit c04e7ed

Please sign in to comment.