i18next-cli 1.82.3 → 1.82.4

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/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.82.3') // This string is replaced with the actual version at build time by rollup
42
+ .version('1.82.4') // 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)');
@@ -342,6 +342,18 @@ function getObjectPropValueExpression(object, propName) {
342
342
  // For shorthand properties like { ns }.
343
343
  (p) => p.type === 'Identifier' && p.value === propName));
344
344
  }
345
+ /**
346
+ * Checks if the options use the interval postProcessor (i18next-intervalPlural-postProcessor),
347
+ * as `postProcess: 'interval'` or `postProcess: ['interval']`. There `count` picks an interval
348
+ * from the plain key, so it gets no plural keys: i18next would find those first and break it.
349
+ *
350
+ * @private
351
+ */
352
+ function usesIntervalPostProcessor(options) {
353
+ const postProcess = options && getObjectPropValueExpression(options, 'postProcess');
354
+ const postProcessors = postProcess?.type === 'ArrayExpression' ? postProcess.elements.map(e => e?.expression) : [postProcess];
355
+ return postProcessors.some(e => e?.type === 'StringLiteral' && e.value === 'interval');
356
+ }
345
357
  /**
346
358
  * Checks if the given template literal has no interpolation expressions
347
359
  *
@@ -397,3 +409,4 @@ exports.lineColumnFromOffset = lineColumnFromOffset;
397
409
  exports.normalizeASTSpans = normalizeASTSpans;
398
410
  exports.normalizeSpansToCharIndices = normalizeSpansToCharIndices;
399
411
  exports.unwrapParens = unwrapParens;
412
+ exports.usesIntervalPostProcessor = usesIntervalPostProcessor;
@@ -381,7 +381,7 @@ class CallExpressionHandler {
381
381
  return undefined;
382
382
  };
383
383
  const hasCount = (() => {
384
- if (!options || !Array.isArray(options.properties))
384
+ if (astUtils.usesIntervalPostProcessor(options) || !options || !Array.isArray(options.properties))
385
385
  return false;
386
386
  for (const p of options.properties) {
387
387
  const name = propNameFromNode(p);
@@ -174,13 +174,13 @@ function extractFromTransComponent(node, config) {
174
174
  // extraction time we can only inspect the AST shape, so we look for any
175
175
  // ObjectExpression interpolation that declares a `count` key.
176
176
  const hasInlineCount = !countAttr && !valuesCountProperty && childrenHaveInlineCount(node.children);
177
- const hasCount = !!countAttr || !!valuesCountProperty || hasInlineCount;
178
177
  const tOptionsAttr = node.opening.attributes?.find((attr) => attr.type === 'JSXAttribute' &&
179
178
  attr.name.type === 'Identifier' &&
180
179
  attr.name.value === 'tOptions');
181
180
  const optionsNode = (tOptionsAttr?.type === 'JSXAttribute' && tOptionsAttr.value?.type === 'JSXExpressionContainer' && tOptionsAttr.value.expression.type === 'ObjectExpression')
182
181
  ? tOptionsAttr.value.expression
183
182
  : undefined;
183
+ const hasCount = (!!countAttr || !!valuesCountProperty || hasInlineCount) && !astUtils.usesIntervalPostProcessor(optionsNode);
184
184
  // Find isOrdinal prop on the <Trans> component
185
185
  const ordinalAttr = node.opening.attributes?.find((attr) => attr.type === 'JSXAttribute' &&
186
186
  attr.name.type === 'Identifier' &&
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.82.3') // This string is replaced with the actual version at build time by rollup
36
+ .version('1.82.4') // 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)');
@@ -340,6 +340,18 @@ function getObjectPropValueExpression(object, propName) {
340
340
  // For shorthand properties like { ns }.
341
341
  (p) => p.type === 'Identifier' && p.value === propName));
342
342
  }
343
+ /**
344
+ * Checks if the options use the interval postProcessor (i18next-intervalPlural-postProcessor),
345
+ * as `postProcess: 'interval'` or `postProcess: ['interval']`. There `count` picks an interval
346
+ * from the plain key, so it gets no plural keys: i18next would find those first and break it.
347
+ *
348
+ * @private
349
+ */
350
+ function usesIntervalPostProcessor(options) {
351
+ const postProcess = options && getObjectPropValueExpression(options, 'postProcess');
352
+ const postProcessors = postProcess?.type === 'ArrayExpression' ? postProcess.elements.map(e => e?.expression) : [postProcess];
353
+ return postProcessors.some(e => e?.type === 'StringLiteral' && e.value === 'interval');
354
+ }
343
355
  /**
344
356
  * Checks if the given template literal has no interpolation expressions
345
357
  *
@@ -383,4 +395,4 @@ function getObjectPropValue(object, propName, identifierResolver, expressionReso
383
395
  return expressionResolver?.(val) ?? ''; // Indicate presence for other types
384
396
  }
385
397
 
386
- export { buildByteToCharMap, collectIgnoredLineRanges, convertSpansToCharIndices, findFirstTokenIndex, getObjectPropValue, getObjectPropValueExpression, getObjectProperty, isSimpleTemplateLiteral, lineColumnFromOffset, normalizeASTSpans, normalizeSpansToCharIndices, unwrapParens };
398
+ export { buildByteToCharMap, collectIgnoredLineRanges, convertSpansToCharIndices, findFirstTokenIndex, getObjectPropValue, getObjectPropValueExpression, getObjectProperty, isSimpleTemplateLiteral, lineColumnFromOffset, normalizeASTSpans, normalizeSpansToCharIndices, unwrapParens, usesIntervalPostProcessor };
@@ -1,7 +1,7 @@
1
1
  import { safePluralRules } from '../../utils/plural-rules.js';
2
2
  import { parseNestedReferences } from '../../utils/nesting.js';
3
3
  import { usesMessageFormat } from '../../utils/message-format.js';
4
- import { getObjectPropValue, unwrapParens, lineColumnFromOffset, isSimpleTemplateLiteral, getObjectPropValueExpression } from './ast-utils.js';
4
+ import { getObjectPropValue, unwrapParens, lineColumnFromOffset, isSimpleTemplateLiteral, getObjectPropValueExpression, usesIntervalPostProcessor } from './ast-utils.js';
5
5
  import { matchesFunctionPattern } from '../utils/function-matcher.js';
6
6
 
7
7
  // Helper to escape regex characters
@@ -379,7 +379,7 @@ class CallExpressionHandler {
379
379
  return undefined;
380
380
  };
381
381
  const hasCount = (() => {
382
- if (!options || !Array.isArray(options.properties))
382
+ if (usesIntervalPostProcessor(options) || !options || !Array.isArray(options.properties))
383
383
  return false;
384
384
  for (const p of options.properties) {
385
385
  const name = propNameFromNode(p);
@@ -1,4 +1,4 @@
1
- import { getObjectPropValueExpression, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
1
+ import { getObjectPropValueExpression, usesIntervalPostProcessor, getObjectPropValue, isSimpleTemplateLiteral } from './ast-utils.js';
2
2
  import { toMessageFormatPlaceholders } from '../../utils/message-format.js';
3
3
  import { createRequire } from 'node:module';
4
4
  import { parseSync } from '@swc/core';
@@ -171,13 +171,13 @@ function extractFromTransComponent(node, config) {
171
171
  // extraction time we can only inspect the AST shape, so we look for any
172
172
  // ObjectExpression interpolation that declares a `count` key.
173
173
  const hasInlineCount = !countAttr && !valuesCountProperty && childrenHaveInlineCount(node.children);
174
- const hasCount = !!countAttr || !!valuesCountProperty || hasInlineCount;
175
174
  const tOptionsAttr = node.opening.attributes?.find((attr) => attr.type === 'JSXAttribute' &&
176
175
  attr.name.type === 'Identifier' &&
177
176
  attr.name.value === 'tOptions');
178
177
  const optionsNode = (tOptionsAttr?.type === 'JSXAttribute' && tOptionsAttr.value?.type === 'JSXExpressionContainer' && tOptionsAttr.value.expression.type === 'ObjectExpression')
179
178
  ? tOptionsAttr.value.expression
180
179
  : undefined;
180
+ const hasCount = (!!countAttr || !!valuesCountProperty || hasInlineCount) && !usesIntervalPostProcessor(optionsNode);
181
181
  // Find isOrdinal prop on the <Trans> component
182
182
  const ordinalAttr = node.opening.attributes?.find((attr) => attr.type === 'JSXAttribute' &&
183
183
  attr.name.type === 'Identifier' &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.82.3",
3
+ "version": "1.82.4",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -130,6 +130,14 @@ export declare function getObjectProperty(object: ObjectExpression, propName: st
130
130
  * @returns The matching value node if found, otherwise undefined.
131
131
  */
132
132
  export declare function getObjectPropValueExpression(object: ObjectExpression, propName: string): Expression | undefined;
133
+ /**
134
+ * Checks if the options use the interval postProcessor (i18next-intervalPlural-postProcessor),
135
+ * as `postProcess: 'interval'` or `postProcess: ['interval']`. There `count` picks an interval
136
+ * from the plain key, so it gets no plural keys: i18next would find those first and break it.
137
+ *
138
+ * @private
139
+ */
140
+ export declare function usesIntervalPostProcessor(options?: ObjectExpression): boolean;
133
141
  /**
134
142
  * Checks if the given template literal has no interpolation expressions
135
143
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAc,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE1F;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CA2BzD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA0BhE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQhH;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA0BpE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAwBhF;AAED;;;;;;;;;GASG;AACH,wBA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