mashpie/i18n-node
### [`v0.10.0`](https://togithub.com/mashpie/i18n-node/releases/0.10.0)
[Compare Source](https://togithub.com/mashpie/i18n-node/compare/0.9.1...0.10.0)
Thanks to [@einfallstoll](https://togithub.com/einfallstoll) i18n got much more developer friendly by adding two extra configuration options for working with translation ~files~ catalogs.
#### Added
- Adds support for priming i18n with static catalogs (PR [#432](https://togithub.com/mashpie/i18n-node/issues/432))
- Adds support for custom callback/hook on missing translations thru `missingKeyFn` option ℗ [#433](https://togithub.com/mashpie/i18n-node/issues/433) )
* * *
#### Examples
##### staticCatalog
Instead of letting i18n load translations from a given directory you may now pass your js object right on configuration, ie:
```js
// DEMO: quick add yaml support on your own
const yaml = require('js-yaml');
const fs = require('fs');
// configure and load translations from different locations
i18n.configure({
staticCatalog: {
de: require('../../locales/de.json'),
en: require('../../locales/wired-en-filename.js'),
fr: yaml.safeLoad(fs.readFileSync('../../locales/yaml/fr/server.yml', 'utf8'));
},
defaultLocale: 'de'
})
```
This opens up for a ton of possible ways to handle translations in your very own desired way. But be warned: "Great power comes with great responsibility".
##### missingKeyFn
Want to get a warning on missing translations? Add missing translations with an indicator? Or even want to try an external service (like deepl.com) to provide an automated translated proposal of a missing phrase?
```js
i18n.configure({
missingKeyFn(locale, value) {
console.warn(`missing translation of "${value}" in [${locale}]!`)
return `${value}-[${locale}]`;
},
defaultLocale: 'de'
})
```
Renovate configuration
:date: Schedule: "every weekday" (UTC).
:vertical_traffic_light: Automerge: Enabled.
:recycle: Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
0.9.1
->0.10.0
Release Notes
mashpie/i18n-node
### [`v0.10.0`](https://togithub.com/mashpie/i18n-node/releases/0.10.0) [Compare Source](https://togithub.com/mashpie/i18n-node/compare/0.9.1...0.10.0) Thanks to [@einfallstoll](https://togithub.com/einfallstoll) i18n got much more developer friendly by adding two extra configuration options for working with translation ~files~ catalogs. #### Added - Adds support for priming i18n with static catalogs (PR [#432](https://togithub.com/mashpie/i18n-node/issues/432)) - Adds support for custom callback/hook on missing translations thru `missingKeyFn` option ℗ [#433](https://togithub.com/mashpie/i18n-node/issues/433) ) * * * #### Examples ##### staticCatalog Instead of letting i18n load translations from a given directory you may now pass your js object right on configuration, ie: ```js // DEMO: quick add yaml support on your own const yaml = require('js-yaml'); const fs = require('fs'); // configure and load translations from different locations i18n.configure({ staticCatalog: { de: require('../../locales/de.json'), en: require('../../locales/wired-en-filename.js'), fr: yaml.safeLoad(fs.readFileSync('../../locales/yaml/fr/server.yml', 'utf8')); }, defaultLocale: 'de' }) ``` This opens up for a ton of possible ways to handle translations in your very own desired way. But be warned: "Great power comes with great responsibility". ##### missingKeyFn Want to get a warning on missing translations? Add missing translations with an indicator? Or even want to try an external service (like deepl.com) to provide an automated translated proposal of a missing phrase? ```js i18n.configure({ missingKeyFn(locale, value) { console.warn(`missing translation of "${value}" in [${locale}]!`) return `${value}-[${locale}]`; }, defaultLocale: 'de' }) ```Renovate configuration
:date: Schedule: "every weekday" (UTC).
:vertical_traffic_light: Automerge: Enabled.
:recycle: Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
:no_bell: Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.