Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit f6e95d0

Browse files
committed
feat: Add disablePluralKeyChecks option
1 parent 0df533f commit f6e95d0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ messages['ordinal-example']({ N: 1 });
4040

4141
## Options (passed as [query parameters](http://webpack.github.io/docs/using-loaders.html#query-parameters))
4242

43-
* `locale` The [CLDR language code](http://www.unicode.org/cldr/charts/29/supplemental/language_territory_information.html) to pass to [messageformat.js](https://messageformat.github.io/messageformat.js/doc/MessageFormat.html). Defaults to `en`.
43+
* [`locale`](https://messageformat.github.io/messageformat.js/doc/MessageFormat.html#MessageFormat) The [CLDR language code](http://www.unicode.org/cldr/charts/29/supplemental/language_territory_information.html) to pass to [messageformat.js](https://messageformat.github.io/messageformat.js/doc/MessageFormat.html). Defaults to `en`.
44+
* [`disablePluralKeyChecks`](https://messageformat.github.io/messageformat.js/doc/MessageFormat.html#disablePluralKeyChecks) By default, messageformat.js throws an error when a statement uses a non-numerical key that will never be matched as a pluralization category for the current locale. Use this argument to disable the validation and allow unused plural keys. Defaults to `false`.
4445

4546
## License
4647

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ module.exports = function(content) {
55
var query = loaderUtils.parseQuery(this.query);
66
var locale = query.locale || 'en';
77
var messages = (Array.isArray(this.inputValue) && typeof this.inputValue[0] === 'object') ? this.inputValue[0] : this.exec(content);
8-
var messageFunctions = new MessageFormat(locale).compile(messages);
8+
var messageFormat = new MessageFormat(locale);
9+
if (query.disablePluralKeyChecks) {
10+
messageFormat.disablePluralKeyChecks();
11+
}
12+
var messageFunctions = messageFormat.compile(messages);
913

1014
this.cacheable && this.cacheable();
1115
this.value = [ messageFunctions ];

0 commit comments

Comments
 (0)