@spintax/core 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -397,6 +397,7 @@ function pluralArity(baseLang) {
397
397
  return 2;
398
398
  }
399
399
  }
400
+ var DEFAULT_PLURAL_ARITY = pluralArity("");
400
401
  function pluralFor(baseLang, n, forms) {
401
402
  const abs = Math.abs(n);
402
403
  const mod10 = abs % 10;
@@ -579,8 +580,8 @@ function checkPlurals(text, idx, locale, out) {
579
580
  out.push(err("plural.nested-brackets", "{plural ...}: forms must not contain nested spintax brackets. Extract via #def first \u2014 a #set is substituted verbatim and would put the brackets straight back.", at));
580
581
  continue;
581
582
  }
583
+ const count = block.formsRaw.split("|").length;
582
584
  if (arity > 0) {
583
- const count = block.formsRaw.split("|").length;
584
585
  if (count !== arity) {
585
586
  out.push(err(
586
587
  "plural.arity",
@@ -588,6 +589,12 @@ function checkPlurals(text, idx, locale, out) {
588
589
  { ...at, data: { expected: arity, got: count } }
589
590
  ));
590
591
  }
592
+ } else if (count !== DEFAULT_PLURAL_ARITY) {
593
+ out.push(warn(
594
+ "plural.locale-missing",
595
+ `{plural ...}: ${count} forms, but no locale was supplied. render defaults to ${DEFAULT_PLURAL_ARITY} forms and leaves this block unresolved \u2014 pass the locale you will render with.`,
596
+ { ...at, data: { got: count, defaultArity: DEFAULT_PLURAL_ARITY } }
597
+ ));
591
598
  }
592
599
  }
593
600
  }