gulp-i18n-update-localization-ids
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -58,3 +58,3 @@ 'use strict'; | ||
static parse(spec) { | ||
const lkey = new LocalizationKey(); | ||
const key = new LocalizationKey(); | ||
ENTRY_REGEXP.lastIndex = 0; | ||
@@ -70,9 +70,9 @@ while (ENTRY_REGEXP.lastIndex < spec.length) { | ||
.forEach(attr => { | ||
if (lkey.has(attr)) { | ||
if (key.has(attr)) { | ||
throw new SyntaxError(`${attr} has multiple localization keys.`); | ||
} | ||
lkey.set(attr, entry[2]); | ||
key.set(attr, entry[2]); | ||
}); | ||
} | ||
return lkey; | ||
return key; | ||
} | ||
@@ -79,0 +79,0 @@ |
{ | ||
"name": "gulp-i18n-update-localization-ids", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Update i18n localization ids in html files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -105,2 +105,51 @@ # gulp-i18n-update-localization-ids | ||
### `mergeOptions(defaults, overrides)` | ||
Utility for merging plugin options. | ||
```js | ||
const mergeOptions = require('gulp-i18n-update-localization-ids/lib/merge-options'); | ||
const task = i18nUpdateLocalizationIds(mergeOptions(defaults, overrides)); | ||
``` | ||
+ defaults `<object>` - Default plugin options. | ||
+ overrides `<object>` - Plugin options to override. | ||
+ returns `<object>` - Merged plugin options. | ||
Options are merged as follows: | ||
+ `whitelist` will contain all entries from defaults and overrides. | ||
+ `ignore` will contain all ignore items from defaults and overrides. | ||
+ all other options will be set from `overrides` or `defaults` if specified. | ||
```js | ||
merge({ | ||
emit: 'onChangeOnly', | ||
whitelist: [ {tagName: 'foo'} ], | ||
ignore: {content: 'bar'} | ||
}, { | ||
idTemplate: x => `foo-${x}`, | ||
whitelist: [ {tagName: 'bar'} ], | ||
ignore: [ | ||
{content: 'foo'}, | ||
{tagName: 'code'} | ||
] | ||
}); | ||
// will be merged to: | ||
{ | ||
whitelist: [ | ||
{tagName: 'foo'}, | ||
{tagName: 'bar'} | ||
], | ||
ignore: [ | ||
{content: 'bar'}, | ||
[ | ||
{content: 'foo'}, | ||
{tagName: 'code'} | ||
] | ||
], | ||
emit: 'onChangeOnly', | ||
idTemplate: x => `foo-${x}` | ||
} | ||
``` | ||
<br> | ||
# Example | ||
@@ -107,0 +156,0 @@ The following example will watch and process your html files during development.<br/> |
37008
11
446
227