@oxy.so/doctor 1.6.0 → 1.6.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/i18n.mjs +14 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxy.so/doctor",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Read-only health checks for Oxy ecosystem repositories",
5
5
  "repository": {
6
6
  "type": "git",
package/src/i18n.mjs CHANGED
@@ -110,14 +110,25 @@ const isLeaf = (value) =>
110
110
  const PLURAL_FORM = /_(?:zero|one|two|few|many|other)$/;
111
111
  const PLURAL_CATEGORIES = ['zero', 'one', 'two', 'few', 'many', 'other'];
112
112
 
113
- /** Whether `node` holds another plural form of the same base as `segment`. */
113
+ const isPluralCategory = (segment) => PLURAL_CATEGORIES.includes(segment);
114
+
115
+ /** An i18n-js plural object, `{ one, other }`: every key a CLDR category, `other` among them. */
116
+ const isPluralObject = (node) =>
117
+ 'other' in node && Object.keys(node).every((segment) => isPluralCategory(segment));
118
+
119
+ /**
120
+ * Whether `node` holds another plural form of the same base as `segment`:
121
+ * i18next's suffixed siblings (`count_one` / `count_many`) or i18n-js's nested
122
+ * plural object (`count.one` / `count.many`).
123
+ */
114
124
  function hasPluralSibling(node, segment) {
125
+ if (isPluralCategory(segment)) return isPluralObject(node);
115
126
  if (!PLURAL_FORM.test(segment)) return false;
116
127
  const base = segment.replace(PLURAL_FORM, '');
117
128
  return PLURAL_CATEGORIES.some((category) => `${base}_${category}` in node);
118
129
  }
119
130
 
120
- const SINGULAR_PLURAL = /_(?:zero|one|two)$/;
131
+ const SINGULAR_PLURAL = /[._](?:zero|one|two)$/;
121
132
 
122
133
  /**
123
134
  * The placeholders a string interpolates. A singular plural form may spell its
@@ -198,7 +209,7 @@ export function checkCatalogs({ locales }, sourceLocale = DEFAULT_SOURCE_LOCALE)
198
209
  for (const [segment, value] of Object.entries(node)) {
199
210
  const key = path ? `${path}.${segment}` : segment;
200
211
  if (!(segment in sourceNode)) {
201
- // Another CLDR plural form of a source key: `_few` / `_many` exist in
212
+ // Another CLDR plural form of a source key: `few` / `many` exist in
202
213
  // languages English has no form for.
203
214
  if (hasPluralSibling(sourceNode, segment)) continue;
204
215
  errors.push({