i18next-cli 1.49.2 → 1.49.3

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
@@ -31,7 +31,7 @@ const program = new commander.Command();
31
31
  program
32
32
  .name('i18next-cli')
33
33
  .description('A unified, high-performance i18next CLI.')
34
- .version('1.49.2'); // This string is replaced with the actual version at build time by rollup
34
+ .version('1.49.3'); // This string is replaced with the actual version at build time by rollup
35
35
  // new: global config override option
36
36
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
37
37
  program
@@ -504,7 +504,8 @@ function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale,
504
504
  // For non-primary locales, we generate forms for that specific locale from CLDR.
505
505
  // Additionally, we generate empty placeholders for ALL other CLDR forms not in the target locale
506
506
  // (so translators can add them manually if needed).
507
- if (hasCount && !isExpandedPlural) {
507
+ // When disablePlurals is true, skip plural expansion entirely and fall through to normal key handling.
508
+ if (hasCount && !isExpandedPlural && !config.extract.disablePlurals) {
508
509
  const parts = String(key).split(pluralSeparator);
509
510
  const isBaseKey = parts.length === 1;
510
511
  if (isBaseKey) {
@@ -309,6 +309,18 @@ class CallExpressionHandler {
309
309
  return false;
310
310
  })();
311
311
  if (hasCount || isOrdinalByKey) {
312
+ // Check if plurals are disabled FIRST, before any plural optimization paths
313
+ if (this.config.extract.disablePlurals) {
314
+ // When plurals are disabled, treat count as a regular option (for interpolation only)
315
+ // Still handle context normally
316
+ if (keysWithContext.length > 0) {
317
+ keysWithContext.forEach(this.pluginContext.addKey);
318
+ }
319
+ else {
320
+ this.pluginContext.addKey({ key: finalKey, ns, defaultValue: dv, explicitDefault: explicitDefaultForBase });
321
+ }
322
+ continue; // This key is fully handled
323
+ }
312
324
  // QUICK PATH: If ALL target locales only have the "other" category,
313
325
  // emit base/context keys directly (avoid generating *_other). This
314
326
  // mirrors the special-case in handlePluralKeys but is placed here as a
@@ -374,25 +386,12 @@ class CallExpressionHandler {
374
386
  catch (e) {
375
387
  // Ignore Intl failures here and fall through to normal logic
376
388
  }
377
- // Check if plurals are disabled
378
- if (this.config.extract.disablePlurals) {
379
- // When plurals are disabled, treat count as a regular option (for interpolation only)
380
- // Still handle context normally
381
- if (keysWithContext.length > 0) {
382
- keysWithContext.forEach(this.pluginContext.addKey);
383
- }
384
- else {
385
- this.pluginContext.addKey({ key: finalKey, ns, defaultValue: dv, explicitDefault: explicitDefaultForBase });
386
- }
387
- }
388
- else {
389
- // Original plural handling logic when plurals are enabled
390
- // Always pass the base key to handlePluralKeys - it will handle context internally.
391
- // Pass explicitDefaultForBase so that when a call-site provided an explicit
392
- // base default (e.g. t('key', 'Default', { count })), plural variant keys
393
- // are treated as explicit and may be synced to that default.
394
- this.handlePluralKeys(finalKey, ns, options, isOrdinalByOption || isOrdinalByKey, finalDefaultValue, explicitPluralForVariants, locationEntry);
395
- }
389
+ // Original plural handling logic when plurals are enabled
390
+ // Always pass the base key to handlePluralKeys - it will handle context internally.
391
+ // Pass explicitDefaultForBase so that when a call-site provided an explicit
392
+ // base default (e.g. t('key', 'Default', { count })), plural variant keys
393
+ // are treated as explicit and may be synced to that default.
394
+ this.handlePluralKeys(finalKey, ns, options, isOrdinalByOption || isOrdinalByKey, finalDefaultValue, explicitPluralForVariants, locationEntry);
396
395
  continue; // This key is fully handled
397
396
  }
398
397
  if (keysWithContext.length > 0) {
@@ -516,8 +515,8 @@ class CallExpressionHandler {
516
515
  context = contextMatch[2];
517
516
  }
518
517
  }
519
- if (hasCount || context !== undefined) {
520
- this.generateNestedPluralKeys(key, nestedNs, hasCount, context);
518
+ if ((hasCount && !this.config.extract.disablePlurals) || context !== undefined) {
519
+ this.generateNestedPluralKeys(key, nestedNs, hasCount && !this.config.extract.disablePlurals, context);
521
520
  }
522
521
  else {
523
522
  this.pluginContext.addKey({ key, ns: nestedNs });
package/dist/esm/cli.js CHANGED
@@ -29,7 +29,7 @@ const program = new Command();
29
29
  program
30
30
  .name('i18next-cli')
31
31
  .description('A unified, high-performance i18next CLI.')
32
- .version('1.49.2'); // This string is replaced with the actual version at build time by rollup
32
+ .version('1.49.3'); // This string is replaced with the actual version at build time by rollup
33
33
  // new: global config override option
34
34
  program.option('-c, --config <path>', 'Path to i18next-cli config file (overrides detection)');
35
35
  program
@@ -502,7 +502,8 @@ function buildNewTranslationsForNs(nsKeys, existingTranslations, config, locale,
502
502
  // For non-primary locales, we generate forms for that specific locale from CLDR.
503
503
  // Additionally, we generate empty placeholders for ALL other CLDR forms not in the target locale
504
504
  // (so translators can add them manually if needed).
505
- if (hasCount && !isExpandedPlural) {
505
+ // When disablePlurals is true, skip plural expansion entirely and fall through to normal key handling.
506
+ if (hasCount && !isExpandedPlural && !config.extract.disablePlurals) {
506
507
  const parts = String(key).split(pluralSeparator);
507
508
  const isBaseKey = parts.length === 1;
508
509
  if (isBaseKey) {
@@ -307,6 +307,18 @@ class CallExpressionHandler {
307
307
  return false;
308
308
  })();
309
309
  if (hasCount || isOrdinalByKey) {
310
+ // Check if plurals are disabled FIRST, before any plural optimization paths
311
+ if (this.config.extract.disablePlurals) {
312
+ // When plurals are disabled, treat count as a regular option (for interpolation only)
313
+ // Still handle context normally
314
+ if (keysWithContext.length > 0) {
315
+ keysWithContext.forEach(this.pluginContext.addKey);
316
+ }
317
+ else {
318
+ this.pluginContext.addKey({ key: finalKey, ns, defaultValue: dv, explicitDefault: explicitDefaultForBase });
319
+ }
320
+ continue; // This key is fully handled
321
+ }
310
322
  // QUICK PATH: If ALL target locales only have the "other" category,
311
323
  // emit base/context keys directly (avoid generating *_other). This
312
324
  // mirrors the special-case in handlePluralKeys but is placed here as a
@@ -372,25 +384,12 @@ class CallExpressionHandler {
372
384
  catch (e) {
373
385
  // Ignore Intl failures here and fall through to normal logic
374
386
  }
375
- // Check if plurals are disabled
376
- if (this.config.extract.disablePlurals) {
377
- // When plurals are disabled, treat count as a regular option (for interpolation only)
378
- // Still handle context normally
379
- if (keysWithContext.length > 0) {
380
- keysWithContext.forEach(this.pluginContext.addKey);
381
- }
382
- else {
383
- this.pluginContext.addKey({ key: finalKey, ns, defaultValue: dv, explicitDefault: explicitDefaultForBase });
384
- }
385
- }
386
- else {
387
- // Original plural handling logic when plurals are enabled
388
- // Always pass the base key to handlePluralKeys - it will handle context internally.
389
- // Pass explicitDefaultForBase so that when a call-site provided an explicit
390
- // base default (e.g. t('key', 'Default', { count })), plural variant keys
391
- // are treated as explicit and may be synced to that default.
392
- this.handlePluralKeys(finalKey, ns, options, isOrdinalByOption || isOrdinalByKey, finalDefaultValue, explicitPluralForVariants, locationEntry);
393
- }
387
+ // Original plural handling logic when plurals are enabled
388
+ // Always pass the base key to handlePluralKeys - it will handle context internally.
389
+ // Pass explicitDefaultForBase so that when a call-site provided an explicit
390
+ // base default (e.g. t('key', 'Default', { count })), plural variant keys
391
+ // are treated as explicit and may be synced to that default.
392
+ this.handlePluralKeys(finalKey, ns, options, isOrdinalByOption || isOrdinalByKey, finalDefaultValue, explicitPluralForVariants, locationEntry);
394
393
  continue; // This key is fully handled
395
394
  }
396
395
  if (keysWithContext.length > 0) {
@@ -514,8 +513,8 @@ class CallExpressionHandler {
514
513
  context = contextMatch[2];
515
514
  }
516
515
  }
517
- if (hasCount || context !== undefined) {
518
- this.generateNestedPluralKeys(key, nestedNs, hasCount, context);
516
+ if ((hasCount && !this.config.extract.disablePlurals) || context !== undefined) {
517
+ this.generateNestedPluralKeys(key, nestedNs, hasCount && !this.config.extract.disablePlurals, context);
519
518
  }
520
519
  else {
521
520
  this.pluginContext.addKey({ key, ns: nestedNs });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.49.2",
3
+ "version": "1.49.3",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAw3B9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EACf,MAA4B,EAC7B,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA8J9B"}
1
+ {"version":3,"file":"translation-manager.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/translation-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAy3B9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,EACvB,MAAM,EAAE,oBAAoB,EAC5B,EACE,uBAA+B,EAC/B,OAAe,EACf,MAA4B,EAC7B,GAAE;IACD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA8J9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"call-expression-handler.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/call-expression-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAA6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