Skip to content
This repository was archived by the owner on Dec 17, 2018. It is now read-only.

Commit 76fef8e

Browse files
committed
Add MessageFormat#disablePluralKeyChecks()
1 parent b4865b0 commit 76fef8e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

parser.pegjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ token
1515
};
1616
}
1717
/ '{' _ arg:id _ ',' _ type:('plural'/'selectordinal') _ ',' _ offset:offset? cases:pluralCase+ _ '}' {
18-
var ls = ((type === 'selectordinal') ? options.ordinal : options.cardinal);
18+
var ls = ((type === 'selectordinal') ? options.ordinal : options.cardinal)
19+
|| ['zero', 'one', 'two', 'few', 'many', 'other'];
1920
if (ls && ls.length) cases.forEach(function(c) {
20-
if (isNaN(c.key) && ls.indexOf(c.key) < 0) throw new Error('Invalid ' + type + ' key: ' + c.key);
21+
if (isNaN(c.key) && ls.indexOf(c.key) < 0) throw new Error(
22+
'Invalid key `' + c.key + '` for argument `' + arg + '`.' +
23+
' Valid ' + type + ' keys for this locale are `' + ls.join('`, `') +
24+
'`, and explicit keys like `=0`.');
2125
});
2226
return {
2327
type: type,
@@ -48,7 +52,7 @@ caseTokens = '{' (_ & '{')? tokens:token* _ '}' { return tokens; }
4852
offset = _ 'offset' _ ':' _ d:digits _ { return d; }
4953

5054
pluralKey
51-
= $('zero'/'one'/'two'/'few'/'many'/'other')
55+
= id
5256
/ '=' d:digits { return d; }
5357

5458
functionParams = _ ',' _ p:id _ { return p; }

0 commit comments

Comments
 (0)