i18next-cli 1.77.0 → 1.79.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/README.md CHANGED
@@ -376,7 +376,8 @@ npx i18next-cli lint
376
376
  - **ICU / MF2 messages** *(error, only with `extract.messageFormat: 'icu'` or `'mf2'`)*: every value in the translation files of all locales is parsed. The linter reports, with file, key and line (JSON files):
377
377
  - syntax errors with the parser's message, e.g. `greeting: ICU syntax error: EXPECT_ARGUMENT_CLOSING_BRACE at column 7`
378
378
  - argument names that differ from the primary language (a renamed or missing `{name}`). `#` in a plural is not an argument
379
- - plural categories of `plural` and `selectordinal` (MF2: `.match` on `:number` or `:integer`) that do not fit the locale. Allowed are the locale's CLDR categories, required are `other` plus every category a whole number from 0 to 1000 selects. So `ru` needs `one`, `few` and `many`, while `fr`, `es`, `it` and `pt` may leave out `many` (only from 1,000,000) and `cs` its `many` (fractions only), and `zero` in English is reported as unused. Exact selectors like `=0` are always allowed, and they count for a category when they cover every whole number it is used for: `=1` covers `one` in English, but not in Russian, where `one` is also 21, 31 and so on. For a locale `Intl` does not know only `other` is required.
379
+ - plural categories of `plural` and `selectordinal` (MF2: `.match` on `:number` or `:integer`) that do not fit the locale. Allowed are the locale's CLDR categories, required are `other` plus every category a whole number below one million selects. So `ru` needs `one`, `few` and `many`, while `fr`, `es`, `it` and `pt` may leave out `many` (only from 1,000,000) and `cs` its `many` (fractions only), and `zero` in English is reported as unused. Exact selectors like `=0` are always allowed, and they count for a category that selects only a few small numbers when they cover them all: `=1` covers `one` in English, but not in Russian, where `one` is also 21, 31 and so on. For a locale `Intl` does not know only `other` is required. A language code with `_` (`ru_RU`, `pt_BR`) is read as `ru-RU`, `pt-BR`.
380
+ - *(warning, MF2 only)* whitespace at the start or end of a pattern that differs from the primary language: `{{ {$count} files}}` shows the space in the app.
380
381
 
381
382
  Empty values count as untranslated and are skipped. See [ICU and MF2 messages](#icu-and-mf2-messages).
382
383
  - **String concatenation** *(warning by default)* — translated strings glued together with `+`, or a sentence split across multiple adjacent translations (`<Trans>` components and/or `{t()}` expressions rendered as siblings). This breaks in languages that reorder or inflect the pieces; use a single key with placeholders instead. Configure with `lint.checkConcatenation`: `'warn'` / `true` (default) reports it without failing the run, `'error'` makes it fail (exit non-zero, useful for CI), and `'off'` / `false` disables it.
package/dist/cjs/cli.js CHANGED
@@ -39,7 +39,7 @@ const program = new commander.Command();
39
39
  program
40
40
  .name('i18next-cli')
41
41
  .description('A unified, high-performance i18next CLI.')
42
- .version('1.77.0') // This string is replaced with the actual version at build time by rollup
42
+ .version('1.79.0') // This string is replaced with the actual version at build time by rollup
43
43
  .addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
44
44
  // new: global config override option
45
45
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
@@ -273,9 +273,9 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
273
273
  catch (err2) {
274
274
  throw new validation.ExtractorError('Failed to process file', file, err2);
275
275
  }
276
- // Fallback for .js files with JSX
276
+ // Fallback for .js and .mjs files with JSX
277
277
  }
278
- else if (effectiveExt === '.js' && !isJSX) {
278
+ else if ((effectiveExt === '.js' || effectiveExt === '.mjs') && !isJSX) {
279
279
  try {
280
280
  ast = await core.parse(code, {
281
281
  syntax: 'ecmascript',
@@ -386,7 +386,7 @@ async function preScanFile(file, astVisitors, config, logger$1 = new logger.Cons
386
386
  throw new validation.ExtractorError('Failed to pre-scan file', file, err2);
387
387
  }
388
388
  }
389
- else if (fileExt === '.js' && !isJSX) {
389
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
390
390
  try {
391
391
  ast = await core.parse(code, { syntax: 'ecmascript', jsx: true, decorators: true, dynamicImport: true, comments: true });
392
392
  }
@@ -257,8 +257,9 @@ async function scanFileForCandidates(content, file, config) {
257
257
  dynamicImport: true,
258
258
  comments: true
259
259
  });
260
+ // Fallback for .js and .mjs files with JSX
260
261
  }
261
- else if (fileExt === '.js' && !isJSX) {
262
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
262
263
  ast = await core.parse(content, {
263
264
  syntax: 'ecmascript',
264
265
  jsx: true,
@@ -590,9 +590,9 @@ class Linter extends node_events.EventEmitter {
590
590
  this.emit('error', wrapped);
591
591
  continue;
592
592
  }
593
- // Fallback for .js files with JSX
593
+ // Fallback for .js and .mjs files with JSX
594
594
  }
595
- else if (fileExt === '.js' && !isJSX) {
595
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
596
596
  try {
597
597
  ast = await core.parse(code, {
598
598
  syntax: 'ecmascript',
@@ -80,7 +80,7 @@ async function loadMessageAnalyzer(format) {
80
80
  const column = err?.location?.start?.column;
81
81
  throw new Error(column ? `${err.message} at column ${column}` : String(err?.message ?? err));
82
82
  }
83
- const shape = { args: new Set(), plurals: [] };
83
+ const shape = { args: new Set(), plurals: [], edges: new Set() };
84
84
  walk(elements, shape);
85
85
  return shape;
86
86
  };
@@ -88,7 +88,15 @@ async function loadMessageAnalyzer(format) {
88
88
  const { parseMessage, validate } = await import('messageformat');
89
89
  return (message) => {
90
90
  const msg = parseMessage(message); // throws a MessageSyntaxError
91
- const shape = { args: validate(msg).variables, plurals: [] }; // validate throws a MessageDataModelError
91
+ const shape = { args: validate(msg).variables, plurals: [], edges: new Set() }; // validate throws a MessageDataModelError
92
+ for (const pattern of msg.type === 'select' ? msg.variants.map(v => v.value) : [msg.pattern]) {
93
+ const first = pattern[0];
94
+ const last = pattern[pattern.length - 1];
95
+ if (typeof first === 'string' && /^\s/.test(first))
96
+ shape.edges.add('start');
97
+ if (typeof last === 'string' && /\s$/.test(last))
98
+ shape.edges.add('end');
99
+ }
92
100
  if (msg.type !== 'select')
93
101
  return shape;
94
102
  msg.selectors.forEach((selector, i) => {
@@ -133,29 +141,38 @@ function mf2PluralType(declarations, name) {
133
141
  return undefined;
134
142
  }
135
143
  const categoryCache = new Map();
144
+ const FIRST_NUMBERS = 10;
136
145
  /**
137
146
  * The plural categories a message for `lng` may and must have: allowed are the locale's CLDR
138
- * categories, required are `other` plus every category a whole number from 0 to 1000 selects.
147
+ * categories, required are `other` plus every category a whole number below one million selects.
139
148
  * So ru needs one/few/many, while fr, es, it and pt may leave out `many` (from 1,000,000 only)
140
149
  * and cs/lt `many` (fractions only). Undefined when Intl does not know the locale.
141
- * Same rule as the Locize AI-review guard and MCP server.
150
+ * Same rule as Locize (`@inweso-dev/i18n-utils` `pluralCategories`); port a fix by hand in both directions.
151
+ * ponytail: samples 0..1999, not every number below one million: CLDR's whole-number rules look at
152
+ * small values and at n % 10, % 100 and % 1000, and a category met from 1000 on selects hundreds of numbers.
142
153
  */
143
154
  function pluralCategories(lng, type) {
144
155
  const cacheKey = `${lng}|${type}`;
145
156
  if (categoryCache.has(cacheKey))
146
157
  return categoryCache.get(cacheKey);
158
+ // a language code may use `_` (ru_RU, zh_Hant_TW), Intl only reads `-`
159
+ const locale = lng.replace(/_/g, '-');
147
160
  let categories;
148
161
  try {
149
- if (Intl.PluralRules.supportedLocalesOf([lng]).length) {
150
- const rules = new Intl.PluralRules(lng, { type });
151
- const numbers = new Map([['other', []]]);
152
- for (let i = 0; i <= 1000; i++) {
162
+ if (Intl.PluralRules.supportedLocalesOf([locale]).length) {
163
+ const rules = new Intl.PluralRules(locale, { type });
164
+ const numbers = new Map([['other', { first: [], more: false }]]);
165
+ for (let i = 0; i < 2000; i++) {
153
166
  const category = rules.select(i);
154
- const list = numbers.get(category);
155
- if (list)
156
- list.push(i);
167
+ let n = numbers.get(category);
168
+ if (!n)
169
+ numbers.set(category, n = { first: [], more: false });
170
+ if (n.first.length < FIRST_NUMBERS)
171
+ n.first.push(i);
157
172
  else
158
- numbers.set(category, [i]);
173
+ n.more = true;
174
+ if (i >= 1000)
175
+ n.more = true;
159
176
  }
160
177
  categories = { allowed: rules.resolvedOptions().pluralCategories, required: [...numbers.keys()], numbers };
161
178
  }
@@ -168,15 +185,21 @@ function pluralCategories(lng, type) {
168
185
  }
169
186
  /**
170
187
  * The required categories a plural lacks. A category other than `other` also counts as present when
171
- * exact selectors cover every whole number it is selected for: en `=1` covers `one`, while ru `=1`
172
- * does not (ru `one` is also 21, 31, ...). This is where the rule deliberately differs from Locize.
188
+ * it selects few small numbers and exact selectors cover them all: en `=1` covers `one`, while ru `=1`
189
+ * does not (ru `one` is also 21, 31, ...).
173
190
  */
174
191
  function missingPluralCategories(plural, lng) {
175
192
  const expected = pluralCategories(lng, plural.type);
176
193
  const exact = new Set(plural.exact);
194
+ const covered = (c) => {
195
+ if (c === 'other')
196
+ return false;
197
+ const n = expected.numbers.get(c);
198
+ return !n.more && n.first.every(i => exact.has(i));
199
+ };
177
200
  return (expected?.required ?? ['other'])
178
201
  .filter(c => !plural.categories.includes(c))
179
- .filter(c => c === 'other' || !expected.numbers.get(c).every(n => exact.has(n)))
202
+ .filter(c => !covered(c))
180
203
  .sort(byCldrOrder);
181
204
  }
182
205
  function* leaves(value, path = []) {
@@ -233,7 +256,7 @@ async function lintMessageFormatResources(config, analyze) {
233
256
  if (typeof value !== 'string' || value === '')
234
257
  continue;
235
258
  const key = path.join(keySeparator);
236
- const report = (text) => problems.push({ path, text: `${key}: ${text}` });
259
+ const report = (text, severity) => problems.push({ path, text: `${key}: ${text}`, severity });
237
260
  let shape;
238
261
  try {
239
262
  shape = analyze(value);
@@ -254,6 +277,10 @@ async function lintMessageFormatResources(config, analyze) {
254
277
  unexpected.length ? `unexpected ${unexpected.join(', ')}` : '',
255
278
  ].filter(Boolean).join(', ')}`);
256
279
  }
280
+ // a correct translation with a visible flaw, so a warning (Locize's soft `whitespace`)
281
+ if ([...source.edges].sort().join() !== [...shape.edges].sort().join()) {
282
+ report(`whitespace at the start or end of a pattern differs from "${primary}", MF2 shows it as text`, 'warning');
283
+ }
257
284
  }
258
285
  for (const plural of shape.plurals) {
259
286
  const expected = pluralCategories(lng, plural.type);
@@ -270,7 +297,7 @@ async function lintMessageFormatResources(config, analyze) {
270
297
  primaryShapes = shapes;
271
298
  if (problems.length) {
272
299
  const lineOf = await lineFinder(file);
273
- issuesByFile.set(file, problems.map(({ path, text }) => ({ text, line: lineOf(path), type: 'messageFormat' })));
300
+ issuesByFile.set(file, problems.map(({ path, text, severity }) => ({ text, line: lineOf(path), type: 'messageFormat', severity })));
274
301
  }
275
302
  }
276
303
  }
package/dist/esm/cli.js CHANGED
@@ -33,7 +33,7 @@ const program = new Command();
33
33
  program
34
34
  .name('i18next-cli')
35
35
  .description('A unified, high-performance i18next CLI.')
36
- .version('1.77.0') // This string is replaced with the actual version at build time by rollup
36
+ .version('1.79.0') // This string is replaced with the actual version at build time by rollup
37
37
  .addHelpText('after', '\nUsing an AI coding agent? Install the i18next-localization skill: npx skills add i18next/i18next-cli\n');
38
38
  // new: global config override option
39
39
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
@@ -271,9 +271,9 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
271
271
  catch (err2) {
272
272
  throw new ExtractorError('Failed to process file', file, err2);
273
273
  }
274
- // Fallback for .js files with JSX
274
+ // Fallback for .js and .mjs files with JSX
275
275
  }
276
- else if (effectiveExt === '.js' && !isJSX) {
276
+ else if ((effectiveExt === '.js' || effectiveExt === '.mjs') && !isJSX) {
277
277
  try {
278
278
  ast = await parse(code, {
279
279
  syntax: 'ecmascript',
@@ -384,7 +384,7 @@ async function preScanFile(file, astVisitors, config, logger = new ConsoleLogger
384
384
  throw new ExtractorError('Failed to pre-scan file', file, err2);
385
385
  }
386
386
  }
387
- else if (fileExt === '.js' && !isJSX) {
387
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
388
388
  try {
389
389
  ast = await parse(code, { syntax: 'ecmascript', jsx: true, decorators: true, dynamicImport: true, comments: true });
390
390
  }
@@ -251,8 +251,9 @@ async function scanFileForCandidates(content, file, config) {
251
251
  dynamicImport: true,
252
252
  comments: true
253
253
  });
254
+ // Fallback for .js and .mjs files with JSX
254
255
  }
255
- else if (fileExt === '.js' && !isJSX) {
256
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
256
257
  ast = await parse(content, {
257
258
  syntax: 'ecmascript',
258
259
  jsx: true,
@@ -588,9 +588,9 @@ class Linter extends EventEmitter {
588
588
  this.emit('error', wrapped);
589
589
  continue;
590
590
  }
591
- // Fallback for .js files with JSX
591
+ // Fallback for .js and .mjs files with JSX
592
592
  }
593
- else if (fileExt === '.js' && !isJSX) {
593
+ else if ((fileExt === '.js' || fileExt === '.mjs') && !isJSX) {
594
594
  try {
595
595
  ast = await parse(code, {
596
596
  syntax: 'ecmascript',
@@ -78,7 +78,7 @@ async function loadMessageAnalyzer(format) {
78
78
  const column = err?.location?.start?.column;
79
79
  throw new Error(column ? `${err.message} at column ${column}` : String(err?.message ?? err));
80
80
  }
81
- const shape = { args: new Set(), plurals: [] };
81
+ const shape = { args: new Set(), plurals: [], edges: new Set() };
82
82
  walk(elements, shape);
83
83
  return shape;
84
84
  };
@@ -86,7 +86,15 @@ async function loadMessageAnalyzer(format) {
86
86
  const { parseMessage, validate } = await import('messageformat');
87
87
  return (message) => {
88
88
  const msg = parseMessage(message); // throws a MessageSyntaxError
89
- const shape = { args: validate(msg).variables, plurals: [] }; // validate throws a MessageDataModelError
89
+ const shape = { args: validate(msg).variables, plurals: [], edges: new Set() }; // validate throws a MessageDataModelError
90
+ for (const pattern of msg.type === 'select' ? msg.variants.map(v => v.value) : [msg.pattern]) {
91
+ const first = pattern[0];
92
+ const last = pattern[pattern.length - 1];
93
+ if (typeof first === 'string' && /^\s/.test(first))
94
+ shape.edges.add('start');
95
+ if (typeof last === 'string' && /\s$/.test(last))
96
+ shape.edges.add('end');
97
+ }
90
98
  if (msg.type !== 'select')
91
99
  return shape;
92
100
  msg.selectors.forEach((selector, i) => {
@@ -131,29 +139,38 @@ function mf2PluralType(declarations, name) {
131
139
  return undefined;
132
140
  }
133
141
  const categoryCache = new Map();
142
+ const FIRST_NUMBERS = 10;
134
143
  /**
135
144
  * The plural categories a message for `lng` may and must have: allowed are the locale's CLDR
136
- * categories, required are `other` plus every category a whole number from 0 to 1000 selects.
145
+ * categories, required are `other` plus every category a whole number below one million selects.
137
146
  * So ru needs one/few/many, while fr, es, it and pt may leave out `many` (from 1,000,000 only)
138
147
  * and cs/lt `many` (fractions only). Undefined when Intl does not know the locale.
139
- * Same rule as the Locize AI-review guard and MCP server.
148
+ * Same rule as Locize (`@inweso-dev/i18n-utils` `pluralCategories`); port a fix by hand in both directions.
149
+ * ponytail: samples 0..1999, not every number below one million: CLDR's whole-number rules look at
150
+ * small values and at n % 10, % 100 and % 1000, and a category met from 1000 on selects hundreds of numbers.
140
151
  */
141
152
  function pluralCategories(lng, type) {
142
153
  const cacheKey = `${lng}|${type}`;
143
154
  if (categoryCache.has(cacheKey))
144
155
  return categoryCache.get(cacheKey);
156
+ // a language code may use `_` (ru_RU, zh_Hant_TW), Intl only reads `-`
157
+ const locale = lng.replace(/_/g, '-');
145
158
  let categories;
146
159
  try {
147
- if (Intl.PluralRules.supportedLocalesOf([lng]).length) {
148
- const rules = new Intl.PluralRules(lng, { type });
149
- const numbers = new Map([['other', []]]);
150
- for (let i = 0; i <= 1000; i++) {
160
+ if (Intl.PluralRules.supportedLocalesOf([locale]).length) {
161
+ const rules = new Intl.PluralRules(locale, { type });
162
+ const numbers = new Map([['other', { first: [], more: false }]]);
163
+ for (let i = 0; i < 2000; i++) {
151
164
  const category = rules.select(i);
152
- const list = numbers.get(category);
153
- if (list)
154
- list.push(i);
165
+ let n = numbers.get(category);
166
+ if (!n)
167
+ numbers.set(category, n = { first: [], more: false });
168
+ if (n.first.length < FIRST_NUMBERS)
169
+ n.first.push(i);
155
170
  else
156
- numbers.set(category, [i]);
171
+ n.more = true;
172
+ if (i >= 1000)
173
+ n.more = true;
157
174
  }
158
175
  categories = { allowed: rules.resolvedOptions().pluralCategories, required: [...numbers.keys()], numbers };
159
176
  }
@@ -166,15 +183,21 @@ function pluralCategories(lng, type) {
166
183
  }
167
184
  /**
168
185
  * The required categories a plural lacks. A category other than `other` also counts as present when
169
- * exact selectors cover every whole number it is selected for: en `=1` covers `one`, while ru `=1`
170
- * does not (ru `one` is also 21, 31, ...). This is where the rule deliberately differs from Locize.
186
+ * it selects few small numbers and exact selectors cover them all: en `=1` covers `one`, while ru `=1`
187
+ * does not (ru `one` is also 21, 31, ...).
171
188
  */
172
189
  function missingPluralCategories(plural, lng) {
173
190
  const expected = pluralCategories(lng, plural.type);
174
191
  const exact = new Set(plural.exact);
192
+ const covered = (c) => {
193
+ if (c === 'other')
194
+ return false;
195
+ const n = expected.numbers.get(c);
196
+ return !n.more && n.first.every(i => exact.has(i));
197
+ };
175
198
  return (expected?.required ?? ['other'])
176
199
  .filter(c => !plural.categories.includes(c))
177
- .filter(c => c === 'other' || !expected.numbers.get(c).every(n => exact.has(n)))
200
+ .filter(c => !covered(c))
178
201
  .sort(byCldrOrder);
179
202
  }
180
203
  function* leaves(value, path = []) {
@@ -231,7 +254,7 @@ async function lintMessageFormatResources(config, analyze) {
231
254
  if (typeof value !== 'string' || value === '')
232
255
  continue;
233
256
  const key = path.join(keySeparator);
234
- const report = (text) => problems.push({ path, text: `${key}: ${text}` });
257
+ const report = (text, severity) => problems.push({ path, text: `${key}: ${text}`, severity });
235
258
  let shape;
236
259
  try {
237
260
  shape = analyze(value);
@@ -252,6 +275,10 @@ async function lintMessageFormatResources(config, analyze) {
252
275
  unexpected.length ? `unexpected ${unexpected.join(', ')}` : '',
253
276
  ].filter(Boolean).join(', ')}`);
254
277
  }
278
+ // a correct translation with a visible flaw, so a warning (Locize's soft `whitespace`)
279
+ if ([...source.edges].sort().join() !== [...shape.edges].sort().join()) {
280
+ report(`whitespace at the start or end of a pattern differs from "${primary}", MF2 shows it as text`, 'warning');
281
+ }
255
282
  }
256
283
  for (const plural of shape.plurals) {
257
284
  const expected = pluralCategories(lng, plural.type);
@@ -268,7 +295,7 @@ async function lintMessageFormatResources(config, analyze) {
268
295
  primaryShapes = shapes;
269
296
  if (problems.length) {
270
297
  const lineOf = await lineFinder(file);
271
- issuesByFile.set(file, problems.map(({ path, text }) => ({ text, line: lineOf(path), type: 'messageFormat' })));
298
+ issuesByFile.set(file, problems.map(({ path, text, severity }) => ({ text, line: lineOf(path), type: 'messageFormat', severity })));
272
299
  }
273
300
  }
274
301
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.77.0",
3
+ "version": "1.79.0",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/instrumenter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAA6B,sBAAsB,EAAiE,MAAM,gBAAgB,CAAA;AAW1N;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkOjC;AA4yCD;;GAEG;AACH,wBAAsB,mBAAmB,IAAK,OAAO,CAAC,OAAO,CAAC,CAU7D;AAID,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAA;AA6B/E;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,kBAAkB,CAAC,CA8B7E;AAED;;GAEG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,OAAO,CAAC,CAOlE;AAwBD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxE;AAiaD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,eAAe,EAAE,EAC7B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,IAAI,CAAC,CAoDf"}
1
+ {"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/instrumenter/core/instrumenter.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAA6B,sBAAsB,EAAiE,MAAM,gBAAgB,CAAA;AAW1N;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAkOjC;AA6yCD;;GAEG;AACH,wBAAsB,mBAAmB,IAAK,OAAO,CAAC,OAAO,CAAC,CAU7D;AAID,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAA;AA6B/E;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,kBAAkB,CAAC,CA8B7E;AAED;;GAEG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,OAAO,CAAC,CAOlE;AAwBD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,IAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWxE;AAiaD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,eAAe,EAAE,EAC7B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,GAAE,MAA4B,GACnC,OAAO,CAAC,IAAI,CAAC,CAoDf"}
@@ -10,6 +10,8 @@ export interface MessageShape {
10
10
  categories: string[];
11
11
  exact: number[];
12
12
  }>;
13
+ /** MF2 only: `start` / `end` when a pattern starts / ends with whitespace, which MF2 keeps as text. */
14
+ edges: Set<'start' | 'end'>;
13
15
  }
14
16
  /** Parses an ICU or MF2 message. Throws an Error with the parser's message on a syntax error. */
15
17
  export type MessageAnalyzer = (message: string) => MessageShape;
@@ -32,17 +34,22 @@ export declare function loadMessageAnalyzer(format: 'icu' | 'mf2'): Promise<Mess
32
34
  interface PluralCategories {
33
35
  /** the locale's CLDR categories */
34
36
  allowed: string[];
35
- /** `other` plus every category a whole number from 0 to 1000 selects */
37
+ /** `other` plus every category a whole number below one million selects */
36
38
  required: string[];
37
- /** per required category, the whole numbers from 0 to 1000 it is selected for */
38
- numbers: Map<string, number[]>;
39
+ /** per required category, the smallest whole numbers it selects (up to 10) and whether there are more */
40
+ numbers: Map<string, {
41
+ first: number[];
42
+ more: boolean;
43
+ }>;
39
44
  }
40
45
  /**
41
46
  * The plural categories a message for `lng` may and must have: allowed are the locale's CLDR
42
- * categories, required are `other` plus every category a whole number from 0 to 1000 selects.
47
+ * categories, required are `other` plus every category a whole number below one million selects.
43
48
  * So ru needs one/few/many, while fr, es, it and pt may leave out `many` (from 1,000,000 only)
44
49
  * and cs/lt `many` (fractions only). Undefined when Intl does not know the locale.
45
- * Same rule as the Locize AI-review guard and MCP server.
50
+ * Same rule as Locize (`@inweso-dev/i18n-utils` `pluralCategories`); port a fix by hand in both directions.
51
+ * ponytail: samples 0..1999, not every number below one million: CLDR's whole-number rules look at
52
+ * small values and at n % 10, % 100 and % 1000, and a category met from 1000 on selects hundreds of numbers.
46
53
  */
47
54
  export declare function pluralCategories(lng: string, type: 'cardinal' | 'ordinal'): PluralCategories | undefined;
48
55
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"message-format.d.ts","sourceRoot":"","sources":["../../src/utils/message-format.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGlE,uCAAuC;AACvC,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB,2HAA2H;IAC3H,OAA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