@alienfast/i18next-loader
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "@alienfast/i18next-loader", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Webpack loader for client embedded i18next locales from json or yaml.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,7 +35,39 @@ # @alienfast/i18next-loader | ||
### Sample i18next config/use | ||
### Option 1: use with webpack.config.js (recommended) | ||
```javascript | ||
module.exports = { | ||
// ... snip | ||
module: { | ||
rules: [ | ||
{ | ||
test: /locales/, | ||
loader: '@alienfast/i18next-loader', | ||
// options here | ||
//query: { overrides: [ '../node_modules/lib/locales' ] } | ||
} | ||
] | ||
} | ||
// ... snip | ||
} | ||
``` | ||
```javascript | ||
// File: app.js | ||
import i18n from 'i18next' | ||
import resources from '../locales' | ||
i18n.init({ | ||
resources | ||
}); | ||
// Use the resources as documented on i18next.com | ||
i18n.t('key') | ||
``` | ||
### Option 2: use with import syntax | ||
```javascript | ||
// File: app.js | ||
import i18n from 'i18next' | ||
import resources from '@alienfast/i18next-loader!../locales/index.js' | ||
@@ -55,2 +87,4 @@ | ||
Options are set via the loader `query`. See webpack documentation for more details regarding how this mechanism works. | ||
The following examples assume you understand these values are used as the `query` value. | ||
@@ -63,9 +97,9 @@ ### Filtering files | ||
#### Only json | ||
```javascript | ||
import resources from "@alienfast/i18next-loader?{include: ['**/*.json']}!../locales/index.js" | ||
```json | ||
{include: ['**/*.json']} | ||
``` | ||
#### Json but exclude one file | ||
```javascript | ||
import resources from "@alienfast/i18next-loader?{include: ['**/*.json', '!**/excludeThis.json']}!../locales/index.js" | ||
```json | ||
{include: ['**/*.json', '!**/excludeThis.json']} | ||
``` | ||
@@ -77,4 +111,4 @@ | ||
```javascript | ||
import resources from "@alienfast/i18next-loader?{overrides: ['../node_modules/lib1/locales']}!../locales/index.js" | ||
```json | ||
{overrides: ['../node_modules/lib1/locales']} | ||
``` | ||
@@ -81,0 +115,0 @@ This configures the loader to work on a file structure like the following: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
237420
137