@messageformat/parser
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -75,3 +75,3 @@ /** | ||
/** @internal */ | ||
export declare type Token = Content | PlainArg | FunctionArg | Select | Octothorpe; | ||
export type Token = Content | PlainArg | FunctionArg | Select | Octothorpe; | ||
/** | ||
@@ -185,3 +185,3 @@ * Text content of the message | ||
*/ | ||
export declare type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'; | ||
export type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'; | ||
/** | ||
@@ -225,2 +225,9 @@ * Options for the parser | ||
strict?: boolean; | ||
/** | ||
* By default, the parser will reject any plural keys that are not valid | ||
* {@link http://cldr.unicode.org/index/cldr-spec/plural-rules | Unicode CLDR} | ||
* plural category keys. | ||
* Setting `strictPluralKeys: false` will disable this check. | ||
*/ | ||
strictPluralKeys?: boolean; | ||
} | ||
@@ -227,0 +234,0 @@ /** |
@@ -134,6 +134,8 @@ "use strict"; | ||
constructor(src, opt) { | ||
var _a, _b, _c, _d; | ||
this.lexer = lexer_js_1.lexer.reset(src); | ||
this.cardinalKeys = (opt && opt.cardinal) || defaultPluralKeys; | ||
this.ordinalKeys = (opt && opt.ordinal) || defaultPluralKeys; | ||
this.strict = (opt && opt.strict) || false; | ||
this.cardinalKeys = (_a = opt === null || opt === void 0 ? void 0 : opt.cardinal) !== null && _a !== void 0 ? _a : defaultPluralKeys; | ||
this.ordinalKeys = (_b = opt === null || opt === void 0 ? void 0 : opt.ordinal) !== null && _b !== void 0 ? _b : defaultPluralKeys; | ||
this.strict = (_c = opt === null || opt === void 0 ? void 0 : opt.strict) !== null && _c !== void 0 ? _c : false; | ||
this.strictPluralKeys = (_d = opt === null || opt === void 0 ? void 0 : opt.strictPluralKeys) !== null && _d !== void 0 ? _d : true; | ||
} | ||
@@ -150,3 +152,3 @@ parse() { | ||
const keys = type === 'plural' ? this.cardinalKeys : this.ordinalKeys; | ||
if (keys.length > 0 && !keys.includes(key)) { | ||
if (this.strictPluralKeys && keys.length > 0 && !keys.includes(key)) { | ||
const msg = `The ${type} case ${key} is not valid in this locale`; | ||
@@ -153,0 +155,0 @@ throw new ParseError(lt, msg); |
{ | ||
"name": "@messageformat/parser", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "An AST parser for ICU MessageFormat strings", | ||
@@ -37,6 +37,5 @@ "keywords": [ | ||
"scripts": { | ||
"build": "tsc", | ||
"extract-api": "api-extractor run --local --verbose" | ||
}, | ||
"gitHead": "33ca9027809512d85bd7d212957afb85e7dd39c4" | ||
"build": "tsc --project tsconfig.build.json", | ||
"extract-api": "api-extractor run --verbose" | ||
} | ||
} |
@@ -174,3 +174,3 @@ # @messageformat/parser | ||
[Messageformat](https://messageformat.github.io/) is an OpenJS Foundation project, and we follow its [Code of Conduct](https://github.com/openjs-foundation/cross-project-council/blob/master/CODE_OF_CONDUCT.md). | ||
[Messageformat](https://messageformat.github.io/) is an OpenJS Foundation project, and we follow its [Code of Conduct](https://code-of-conduct.openjsf.org/). | ||
@@ -177,0 +177,0 @@ <a href="https://openjsf.org"> |
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
677
32303