i18next-cli 1.30.5 → 1.31.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
@@ -427,6 +427,10 @@ export default defineConfig({
427
427
  /** If true, keys that are not found in the source code will be removed from translation files. (default: true) */
428
428
  removeUnusedKeys: true,
429
429
 
430
+ // When true (default), the extractor also scans code comments for t(...) / Trans examples and will extract keys found there.
431
+ // Set to false to ignore translation-like patterns in comments (useful to avoid extracting example/documentation strings).
432
+ extractFromComments: true,
433
+
430
434
  // Control whether base plural forms are generated when context is present
431
435
  // When false, t('key', { context: 'male', count: 1 }) will only generate
432
436
  // key_male_one, key_male_other but NOT key_one, key_other
package/dist/cjs/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("commander"),o=require("chokidar"),t=require("glob"),n=require("minimatch"),i=require("chalk"),r=require("./config.js"),a=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti"),require("@croct/json5-parser");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),d=require("./init.js"),g=require("./linter.js"),f=require("./status.js"),p=require("./locize.js"),y=require("./rename-key.js");const m=new e.Command;m.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.30.5"),m.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),m.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").option("--sync-all","Sync primary language values with default values from code AND clear synced keys in all other locales.").action(async e=>{try{const t=m.opts().config,i=await r.ensureConfig(t),a=async()=>{const o=!!e.syncPrimary||!!e.syncAll,t=await c.runExtractor(i,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:o,syncAll:!!e.syncAll});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.extract.input),t=h(i.extract.ignore),r=w(i.extract.output),c=[...t,...r].filter(Boolean),s=e.filter(e=>!c.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),m.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,o)=>{const t=m.opts().config;let n=await r.loadConfig(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await a.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await f.runStatus(n,{detail:e,namespace:o.namespace})}),m.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const t=m.opts().config,i=await r.ensureConfig(t),a=()=>s.runTypesGenerator(i);if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.types?.input||[]),t=[...h(i.extract?.ignore)].filter(Boolean),r=e.filter(e=>!t.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}),m.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=m.opts().config,o=await r.ensureConfig(e);await l.runSyncer(o)}),m.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),m.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d.runInit),m.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const t=m.opts().config,c=async()=>{let e=await r.loadConfig(t);if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await a.detectConfig();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=o}await g.runLinterCli(e)};if(await c(),e.watch){console.log("\nWatching for changes...");const e=await r.loadConfig(t);if(e?.extract?.input){const t=await x(e.extract.input),i=[...h(e.extract.ignore),...w(e.extract.output)].filter(Boolean),r=t.filter(e=>!i.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),c()})}}}),m.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeSync(t,e)}),m.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeDownload(t,e)}),m.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeMigrate(t,e)}),m.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(e,o,t)=>{try{const n=m.opts().config,a=await r.ensureConfig(n),c=await y.runRenameKey(a,e,o,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(e=>console.error(` - ${e}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((e,o)=>e+o.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${e}"`))}catch(e){console.error(i.red("Error renaming key:"),e),process.exit(1)}}),m.parse(process.argv);const h=e=>Array.isArray(e)?e:e?[e]:[],w=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],x=async(e=[])=>{const o=h(e),n=await Promise.all(o.map(e=>t.glob(e||"",{nodir:!0})));return Array.from(new Set(n.flat()))};exports.program=m;
2
+ "use strict";var e=require("commander"),o=require("chokidar"),t=require("glob"),n=require("minimatch"),i=require("chalk"),r=require("./config.js"),a=require("./heuristic-config.js"),c=require("./extractor/core/extractor.js");require("node:path"),require("node:fs/promises"),require("jiti"),require("@croct/json5-parser");var s=require("./types-generator.js"),l=require("./syncer.js"),u=require("./migrator.js"),d=require("./init.js"),g=require("./linter.js"),f=require("./status.js"),p=require("./locize.js"),y=require("./rename-key.js");const m=new e.Command;m.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.31.0"),m.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),m.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").option("--sync-all","Sync primary language values with default values from code AND clear synced keys in all other locales.").action(async e=>{try{const t=m.opts().config,i=await r.ensureConfig(t),a=async()=>{const o=!!e.syncPrimary||!!e.syncAll,t=await c.runExtractor(i,{isWatchMode:!!e.watch,isDryRun:!!e.dryRun,syncPrimaryWithDefaults:o,syncAll:!!e.syncAll});return e.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):e.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.extract.input),t=h(i.extract.ignore),r=w(i.extract.output),c=[...t,...r].filter(Boolean),s=e.filter(e=>!c.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}catch(e){console.error("Error running extractor:",e),process.exit(1)}}),m.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(e,o)=>{const t=m.opts().config;let n=await r.loadConfig(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await a.detectConfig();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=e}await f.runStatus(n,{detail:e,namespace:o.namespace})}),m.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async e=>{const t=m.opts().config,i=await r.ensureConfig(t),a=()=>s.runTypesGenerator(i);if(await a(),e.watch){console.log("\nWatching for changes...");const e=await x(i.types?.input||[]),t=[...h(i.extract?.ignore)].filter(Boolean),r=e.filter(e=>!t.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),a()})}}),m.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const e=m.opts().config,o=await r.ensureConfig(e);await l.runSyncer(o)}),m.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async e=>{await u.runMigrator(e)}),m.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(d.runInit),m.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async e=>{const t=m.opts().config,c=async()=>{let e=await r.loadConfig(t);if(!e){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await a.detectConfig();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),e=o}await g.runLinterCli(e)};if(await c(),e.watch){console.log("\nWatching for changes...");const e=await r.loadConfig(t);if(e?.extract?.input){const t=await x(e.extract.input),i=[...h(e.extract.ignore),...w(e.extract.output)].filter(Boolean),r=t.filter(e=>!i.some(o=>n.minimatch(e,o,{dot:!0})));o.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",e=>{console.log(`\nFile changed: ${e}`),c()})}}}),m.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeSync(t,e)}),m.command("locize-download").description("Download all translations from your locize project.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeDownload(t,e)}),m.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async e=>{const o=m.opts().config,t=await r.ensureConfig(o);await p.runLocizeMigrate(t,e)}),m.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(e,o,t)=>{try{const n=m.opts().config,a=await r.ensureConfig(n),c=await y.runRenameKey(a,e,o,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(e=>console.error(` - ${e}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((e,o)=>e+o.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${e}"`))}catch(e){console.error(i.red("Error renaming key:"),e),process.exit(1)}}),m.parse(process.argv);const h=e=>Array.isArray(e)?e:e?[e]:[],w=e=>e&&"string"==typeof e?[e.replace(/\{\{[^}]+\}\}/g,"*")]:[],x=async(e=[])=>{const o=h(e),n=await Promise.all(o.map(e=>t.glob(e||"",{nodir:!0})));return Array.from(new Set(n.flat()))};exports.program=m;
@@ -1 +1 @@
1
- "use strict";var t=require("ora"),e=require("chalk"),a=require("@swc/core"),r=require("node:fs/promises"),n=require("node:path"),o=require("./key-finder.js"),s=require("./translation-manager.js"),i=require("../../utils/validation.js"),c=require("../parsers/comment-parser.js"),l=require("../../utils/logger.js"),u=require("../../utils/file-utils.js"),d=require("../../utils/funnel-msg-tracker.js");exports.extract=async function(t,{syncPrimaryWithDefaults:e=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(e=>e!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:a,objectKeys:r}=await o.findKeys(t);return s.getTranslations(a,r,t,{syncPrimaryWithDefaults:e})},exports.processFile=async function(t,o,s,u,d,y=new l.ConsoleLogger){try{let e=await r.readFile(t,"utf-8");for(const a of o)try{const r=await(a.onLoad?.(e,t));void 0!==r&&(e=r)}catch(t){y.warn(`Plugin ${a.name} onLoad failed:`,t)}const l=n.extname(t).toLowerCase(),p=".ts"===l||".tsx"===l||".mts"===l||".cts"===l,m=".tsx"===l,g=".jsx"===l;let f;try{f=await a.parse(e,{syntax:p?"typescript":"ecmascript",tsx:m,jsx:g,decorators:!0,dynamicImport:!0,comments:!0})}catch(r){if(".ts"!==l||m){if(".js"!==l||g)throw new i.ExtractorError("Failed to process file",t,r);try{f=await a.parse(e,{syntax:"ecmascript",jsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),y.info?.(`Parsed ${t} using JSX fallback`)}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}}else try{f=await a.parse(e,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),y.info?.(`Parsed ${t} using TSX fallback`)}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}}u.getVarFromScope=s.getVarFromScope.bind(s),s.setCurrentFile(t,e),s.visit(f),c.extractKeysFromComments(e,u,d,s.getVarFromScope.bind(s))}catch(a){y.warn(`${e.yellow("Skipping file due to error:")} ${t}`),y.warn(` ${a.message}`)}},exports.runExtractor=async function(a,{isWatchMode:c=!1,isDryRun:y=!1,syncPrimaryWithDefaults:p=!1,syncAll:m=!1}={},g=new l.ConsoleLogger){a.extract.primaryLanguage||=a.locales[0]||"en",a.extract.secondaryLanguages||=a.locales.filter(t=>t!==a?.extract?.primaryLanguage),a.extract.functions||=["t","*.t"],a.extract.transComponents||=["Trans"],i.validateExtractorConfig(a);const f=a.plugins||[],x=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:i}=await o.findKeys(a,g);x.text=`Found ${t.size} unique keys. Updating translation files...`;const c=await s.getTranslations(t,i,a,{syncPrimaryWithDefaults:p,syncAll:m});let l=!1;for(const t of c)if(t.updated&&(l=!0,!y)){const o=a.extract.outputFormat??(t.path.endsWith(".json5")?"json5":"json"),s="json5"===o?await u.loadRawJson5Content(t.path)??void 0:void 0,i=u.serializeTranslationFile(t.newTranslations,o,a.extract.indentation,s);await r.mkdir(n.dirname(t.path),{recursive:!0}),await r.writeFile(t.path,i),g.info(e.green(`Updated: ${t.path}`))}if(f.length>0){x.text="Running post-extraction plugins...";for(const t of f)await(t.afterSync?.(c,a))}return x.succeed(e.bold("Extraction complete!")),l&&await async function(){if(!await d.shouldShowFunnel("extract"))return;return console.log(e.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${e.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${e.cyan("https://youtu.be/joPsZghT3wM")}`),d.recordFunnelShown("extract")}(),l}catch(t){throw x.fail(e.red("Extraction failed.")),t}};
1
+ "use strict";var t=require("ora"),e=require("chalk"),a=require("@swc/core"),r=require("node:fs/promises"),o=require("node:path"),n=require("./key-finder.js"),s=require("./translation-manager.js"),i=require("../../utils/validation.js"),c=require("../parsers/comment-parser.js"),l=require("../../utils/logger.js"),u=require("../../utils/file-utils.js"),d=require("../../utils/funnel-msg-tracker.js");exports.extract=async function(t,{syncPrimaryWithDefaults:e=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(e=>e!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:a,objectKeys:r}=await n.findKeys(t);return s.getTranslations(a,r,t,{syncPrimaryWithDefaults:e})},exports.processFile=async function(t,n,s,u,d,y=new l.ConsoleLogger){try{let e=await r.readFile(t,"utf-8");for(const a of n)try{const r=await(a.onLoad?.(e,t));void 0!==r&&(e=r)}catch(t){y.warn(`Plugin ${a.name} onLoad failed:`,t)}const l=o.extname(t).toLowerCase(),m=".ts"===l||".tsx"===l||".mts"===l||".cts"===l,p=".tsx"===l,g=".jsx"===l;let f;try{f=await a.parse(e,{syntax:m?"typescript":"ecmascript",tsx:p,jsx:g,decorators:!0,dynamicImport:!0,comments:!0})}catch(r){if(".ts"!==l||p){if(".js"!==l||g)throw new i.ExtractorError("Failed to process file",t,r);try{f=await a.parse(e,{syntax:"ecmascript",jsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),y.info?.(`Parsed ${t} using JSX fallback`)}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}}else try{f=await a.parse(e,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),y.info?.(`Parsed ${t} using TSX fallback`)}catch(e){throw new i.ExtractorError("Failed to process file",t,e)}}u.getVarFromScope=s.getVarFromScope.bind(s),s.setCurrentFile(t,e),s.visit(f),!1!==d.extract.extractFromComments&&c.extractKeysFromComments(e,u,d,s.getVarFromScope.bind(s))}catch(a){y.warn(`${e.yellow("Skipping file due to error:")} ${t}`),y.warn(` ${a.message}`)}},exports.runExtractor=async function(a,{isWatchMode:c=!1,isDryRun:y=!1,syncPrimaryWithDefaults:m=!1,syncAll:p=!1}={},g=new l.ConsoleLogger){a.extract.primaryLanguage||=a.locales[0]||"en",a.extract.secondaryLanguages||=a.locales.filter(t=>t!==a?.extract?.primaryLanguage),a.extract.functions||=["t","*.t"],a.extract.transComponents||=["Trans"],i.validateExtractorConfig(a);const f=a.plugins||[],x=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:i}=await n.findKeys(a,g);x.text=`Found ${t.size} unique keys. Updating translation files...`;const c=await s.getTranslations(t,i,a,{syncPrimaryWithDefaults:m,syncAll:p});let l=!1;for(const t of c)if(t.updated&&(l=!0,!y)){const n=a.extract.outputFormat??(t.path.endsWith(".json5")?"json5":"json"),s="json5"===n?await u.loadRawJson5Content(t.path)??void 0:void 0,i=u.serializeTranslationFile(t.newTranslations,n,a.extract.indentation,s);await r.mkdir(o.dirname(t.path),{recursive:!0}),await r.writeFile(t.path,i),g.info(e.green(`Updated: ${t.path}`))}if(f.length>0){x.text="Running post-extraction plugins...";for(const t of f)await(t.afterSync?.(c,a))}return x.succeed(e.bold("Extraction complete!")),l&&await async function(){if(!await d.shouldShowFunnel("extract"))return;return console.log(e.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${e.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${e.cyan("https://youtu.be/joPsZghT3wM")}`),d.recordFunnelShown("extract")}(),l}catch(t){throw x.fail(e.red("Extraction failed.")),t}};
@@ -1 +1 @@
1
- "use strict";var e=require("./jsx-parser.js"),t=require("./ast-utils.js");exports.JSXHandler=class{config;pluginContext;expressionResolver;getCurrentFile;getCurrentCode;lastSearchIndex=0;constructor(e,t,n,o,i){this.config=e,this.pluginContext=t,this.expressionResolver=n,this.getCurrentFile=o,this.getCurrentCode=i}resetSearchIndex(){this.lastSearchIndex=0}getLocationFromNode(e){const t=this.getCurrentCode();let n;if("JSXElement"===e.type&&e.opening){const t=e.opening.name?.value;t&&(n=`<${t}`)}if(!n)return;const o=t.indexOf(n,this.lastSearchIndex);if(-1===o)return;this.lastSearchIndex=o+n.length;const i=t.substring(0,o).split("\n");return{line:i.length,column:i[i.length-1].length}}handleJSXElement(t,n){const o=this.getElementName(t);if(o&&(this.config.extract.transComponents||["Trans"]).includes(o)){const o=e.extractFromTransComponent(t,this.config),i=[];if(o){if(o.keyExpression){const e=this.expressionResolver.resolvePossibleKeyStringValues(o.keyExpression);i.push(...e)}else i.push(o.serializedChildren);let e;const{contextExpression:s,optionsNode:a,defaultValue:l,hasCount:r,isOrdinal:u,serializedChildren:c}=o,f=this.getLocationFromNode(t),d=f?[{file:this.getCurrentFile(),line:f.line,column:f.column}]:void 0;if(o.ns){const{ns:t}=o;e=i.map(e=>({key:e,ns:t,defaultValue:l||c,hasCount:r,isOrdinal:u,locations:d}))}else{e=i.map(e=>{const t=this.config.extract.nsSeparator??":";let n;if(t&&e.includes(t)){let o;[n,...o]=e.split(t),e=o.join(t)}return{key:e,ns:n,defaultValue:l||c,hasCount:r,isOrdinal:u,explicitDefault:o.explicitDefault,locations:d}});const s=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"t"===e.name.value);if("JSXAttribute"===s?.type&&"JSXExpressionContainer"===s.value?.type&&"Identifier"===s.value.expression.type){const t=n(s.value.expression.value);if(t?.defaultNs&&e.forEach(e=>{e.ns||(e.ns=t.defaultNs)}),t?.keyPrefix){const n=this.config.extract.keySeparator??".";for(const o of e){let e=o.key;if(e=!1!==n?String(t.keyPrefix).endsWith(String(n))?`${t.keyPrefix}${e}`:`${t.keyPrefix}${n}${e}`:`${t.keyPrefix}${e}`,!1!==n){if(String(e).split(String(n)).some(e=>""===e.trim()))continue}o.key=e}}}}if(e.forEach(e=>{e.ns||(e.ns=this.config.extract.defaultNS)}),s&&r)if(this.config.extract.disablePlurals){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0)if("StringLiteral"===s.type)for(const o of t)for(const t of e){const e=`${t.key}${n}${o}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}else{e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})});for(const o of t)for(const t of e){const e=`${t.key}${n}${o}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),o=!!n,i=this.expressionResolver.resolvePossibleContextStringValues(s),l=this.config.extract.contextSeparator??"_";if(i.length>0){e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,void 0,e.locations,e.key));for(const t of i)for(const n of e){const e=`${n.key}${l}${t}`;this.generatePluralKeysForTrans(e,n.defaultValue,n.ns,o,a,n.explicitDefault,n.locations,n.key)}}else e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,e.explicitDefault,e.locations))}else if(s){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0){for(const o of t)for(const{key:t,ns:i,defaultValue:s,locations:a}of e)this.pluginContext.addKey({key:`${t}${n}${o}`,ns:i,defaultValue:s,locations:a});"StringLiteral"!==s.type&&e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else if(r)if(this.config.extract.disablePlurals)e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})});else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),o=!!n;e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,e.explicitDefault,e.locations))}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})})}}}generatePluralKeysForTrans(e,n,o,i,s,a,l,r){try{const u=i?"ordinal":"cardinal",c=new Intl.PluralRules(this.config.extract?.primaryLanguage,{type:u}).resolvedOptions().pluralCategories,f=this.config.extract.pluralSeparator??"_";let d,p;if(s&&(d=t.getObjectPropValue(s,`defaultValue${f}other`),p=t.getObjectPropValue(s,`defaultValue${f}ordinal${f}other`)),1===c.length&&"other"===c[0]){const u=s?t.getObjectPropValue(s,`defaultValue${f}other`):void 0,c="string"==typeof u?u:"string"==typeof n?n:e;return void this.pluginContext.addKey({key:e,ns:o,defaultValue:c,hasCount:!0,isOrdinal:i,explicitDefault:Boolean(a||"string"==typeof u||"string"==typeof d),locations:l,keyAcceptingContext:r})}for(const u of c){const c=i?`defaultValue${f}ordinal${f}${u}`:`defaultValue${f}${u}`,y=s?t.getObjectPropValue(s,c):void 0;let g;g="string"==typeof y?y:"one"===u&&"string"==typeof n?n:i&&"string"==typeof p?p:i||"string"!=typeof d?"string"==typeof n?n:e:d;const h=i?`${e}${f}ordinal${f}${u}`:`${e}${f}${u}`;this.pluginContext.addKey({key:h,ns:o,defaultValue:g,hasCount:!0,isOrdinal:i,explicitDefault:Boolean(a||"string"==typeof y||"string"==typeof d),locations:l,keyAcceptingContext:r})}}catch(t){this.pluginContext.addKey({key:e,ns:o,defaultValue:n,locations:l})}}getElementName(e){if("Identifier"===e.opening.name.type)return e.opening.name.value;if("JSXMemberExpression"===e.opening.name.type){let t=e.opening.name;const n=[];for(;"JSXMemberExpression"===t.type;)"Identifier"===t.property.type&&n.unshift(t.property.value),t=t.object;return"Identifier"===t.type&&n.unshift(t.value),n.join(".")}}};
1
+ "use strict";var e=require("./jsx-parser.js"),t=require("./ast-utils.js");exports.JSXHandler=class{config;pluginContext;expressionResolver;getCurrentFile;getCurrentCode;lastSearchIndex=0;constructor(e,t,n,o,i){this.config=e,this.pluginContext=t,this.expressionResolver=n,this.getCurrentFile=o,this.getCurrentCode=i}resetSearchIndex(){this.lastSearchIndex=0}getLocationFromNode(e){const t=this.getCurrentCode();let n;if("JSXElement"===e.type&&e.opening){const t=e.opening.name?.value;t&&(n=`<${t}`)}if(!n)return;const o=t.indexOf(n,this.lastSearchIndex);if(-1===o)return;this.lastSearchIndex=o+n.length;const i=t.substring(0,o).split("\n");return{line:i.length,column:i[i.length-1].length}}handleJSXElement(t,n){const o=this.getElementName(t);if(o&&(this.config.extract.transComponents||["Trans"]).includes(o)){const o=e.extractFromTransComponent(t,this.config),i=[];if(o){if(o.keyExpression){const e=this.expressionResolver.resolvePossibleKeyStringValues(o.keyExpression);i.push(...e)}else i.push(o.serializedChildren);let e;const{contextExpression:s,optionsNode:a,defaultValue:l,hasCount:r,isOrdinal:u,serializedChildren:c}=o,f=this.getLocationFromNode(t),d=f?[{file:this.getCurrentFile(),line:f.line,column:f.column}]:void 0;if(o.ns){const{ns:t}=o;e=i.map(e=>({key:e,ns:t,defaultValue:l||c,hasCount:r,isOrdinal:u,locations:d}))}else{e=i.map(e=>{const t=this.config.extract.nsSeparator??":";let n;if(t&&e.includes(t)){let o;[n,...o]=e.split(t),e=o.join(t)}return{key:e,ns:n,defaultValue:l||c,hasCount:r,isOrdinal:u,explicitDefault:o.explicitDefault,locations:d}});const s=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"t"===e.name.value);if("JSXAttribute"===s?.type&&"JSXExpressionContainer"===s.value?.type&&"Identifier"===s.value.expression.type){const t=n(s.value.expression.value);if(t?.defaultNs&&e.forEach(e=>{e.ns||(e.ns=t.defaultNs)}),t?.keyPrefix){const n=this.config.extract.keySeparator??".";for(const o of e){let e=o.key;if(e=!1!==n?String(t.keyPrefix).endsWith(String(n))?`${t.keyPrefix}${e}`:`${t.keyPrefix}${n}${e}`:`${t.keyPrefix}${e}`,!1!==n){if(String(e).split(String(n)).some(e=>""===e.trim()))continue}o.key=e}}}}if(e.forEach(e=>{e.ns||(e.ns=this.config.extract.defaultNS)}),s&&r)if(this.config.extract.disablePlurals){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0)if("StringLiteral"===s.type)for(const o of t)for(const t of e){const e=`${t.key}${n}${o}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}else{e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})});for(const o of t)for(const t of e){const e=`${t.key}${n}${o}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),o=!!n,i=this.expressionResolver.resolvePossibleContextStringValues(s),l=this.config.extract.contextSeparator??"_";if(i.length>0){!1!==this.config.extract.generateBasePluralForms&&e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,void 0,e.locations,e.key));for(const t of i)for(const n of e){const e=`${n.key}${l}${t}`;this.generatePluralKeysForTrans(e,n.defaultValue,n.ns,o,a,n.explicitDefault,n.locations,n.key)}}else e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,e.explicitDefault,e.locations))}else if(s){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0){for(const o of t)for(const{key:t,ns:i,defaultValue:s,locations:a}of e)this.pluginContext.addKey({key:`${t}${n}${o}`,ns:i,defaultValue:s,locations:a});"StringLiteral"!==s.type&&e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else if(r)if(this.config.extract.disablePlurals)e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})});else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),o=!!n;e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,o,a,e.explicitDefault,e.locations))}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})})}}}generatePluralKeysForTrans(e,n,o,i,s,a,l,r){try{const u=i?"ordinal":"cardinal",c=new Intl.PluralRules(this.config.extract?.primaryLanguage,{type:u}).resolvedOptions().pluralCategories,f=this.config.extract.pluralSeparator??"_";let d,p;if(s&&(d=t.getObjectPropValue(s,`defaultValue${f}other`),p=t.getObjectPropValue(s,`defaultValue${f}ordinal${f}other`)),1===c.length&&"other"===c[0]){const u=s?t.getObjectPropValue(s,`defaultValue${f}other`):void 0,c="string"==typeof u?u:"string"==typeof n?n:e;return void this.pluginContext.addKey({key:e,ns:o,defaultValue:c,hasCount:!0,isOrdinal:i,explicitDefault:Boolean(a||"string"==typeof u||"string"==typeof d),locations:l,keyAcceptingContext:r})}for(const u of c){const c=i?`defaultValue${f}ordinal${f}${u}`:`defaultValue${f}${u}`,y=s?t.getObjectPropValue(s,c):void 0;let g;g="string"==typeof y?y:"one"===u&&"string"==typeof n?n:i&&"string"==typeof p?p:i||"string"!=typeof d?"string"==typeof n?n:e:d;const h=i?`${e}${f}ordinal${f}${u}`:`${e}${f}${u}`;this.pluginContext.addKey({key:h,ns:o,defaultValue:g,hasCount:!0,isOrdinal:i,explicitDefault:Boolean(a||"string"==typeof y||"string"==typeof d),locations:l,keyAcceptingContext:r})}}catch(t){this.pluginContext.addKey({key:e,ns:o,defaultValue:n,locations:l})}}getElementName(e){if("Identifier"===e.opening.name.type)return e.opening.name.value;if("JSXMemberExpression"===e.opening.name.type){let t=e.opening.name;const n=[];for(;"JSXMemberExpression"===t.type;)"Identifier"===t.property.type&&n.unshift(t.property.value),t=t.object;return"Identifier"===t.type&&n.unshift(t.value),n.join(".")}}};
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as o}from"commander";import e from"chokidar";import{glob as t}from"glob";import{minimatch as n}from"minimatch";import i from"chalk";import{ensureConfig as a,loadConfig as r}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import"@croct/json5-parser";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as f}from"./migrator.js";import{runInit as m}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";import{runRenameKey as w}from"./rename-key.js";const x=new o;x.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.30.5"),x.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),x.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").option("--sync-all","Sync primary language values with default values from code AND clear synced keys in all other locales.").action(async o=>{try{const t=x.opts().config,i=await a(t),r=async()=>{const e=!!o.syncPrimary||!!o.syncAll,t=await s(i,{isWatchMode:!!o.watch,isDryRun:!!o.dryRun,syncPrimaryWithDefaults:e,syncAll:!!o.syncAll});return o.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):o.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await r(),o.watch){console.log("\nWatching for changes...");const o=await v(i.extract.input),t=j(i.extract.ignore),a=k(i.extract.output),c=[...t,...a].filter(Boolean),s=o.filter(o=>!c.some(e=>n(o,e,{dot:!0})));e.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}catch(o){console.error("Error running extractor:",o),process.exit(1)}}),x.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(o,e)=>{const t=x.opts().config;let n=await r(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await c();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=o}await g(n,{detail:o,namespace:e.namespace})}),x.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async o=>{const t=x.opts().config,i=await a(t),r=()=>l(i);if(await r(),o.watch){console.log("\nWatching for changes...");const o=await v(i.types?.input||[]),t=[...j(i.extract?.ignore)].filter(Boolean),a=o.filter(o=>!t.some(e=>n(o,e,{dot:!0})));e.watch(a,{persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}),x.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const o=x.opts().config,e=await a(o);await p(e)}),x.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async o=>{await f(o)}),x.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(m),x.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async o=>{const t=x.opts().config,a=async()=>{let o=await r(t);if(!o){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),o=e}await d(o)};if(await a(),o.watch){console.log("\nWatching for changes...");const o=await r(t);if(o?.extract?.input){const t=await v(o.extract.input),i=[...j(o.extract.ignore),...k(o.extract.output)].filter(Boolean),r=t.filter(o=>!i.some(e=>n(o,e,{dot:!0})));e.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}}),x.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async o=>{const e=x.opts().config,t=await a(e);await u(t,o)}),x.command("locize-download").description("Download all translations from your locize project.").action(async o=>{const e=x.opts().config,t=await a(e);await y(t,o)}),x.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async o=>{const e=x.opts().config,t=await a(e);await h(t,o)}),x.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(o,e,t)=>{try{const n=x.opts().config,r=await a(n),c=await w(r,o,e,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(o=>console.error(` - ${o}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((o,e)=>o+e.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${o}"`))}catch(o){console.error(i.red("Error renaming key:"),o),process.exit(1)}}),x.parse(process.argv);const j=o=>Array.isArray(o)?o:o?[o]:[],k=o=>o&&"string"==typeof o?[o.replace(/\{\{[^}]+\}\}/g,"*")]:[],v=async(o=[])=>{const e=j(o),n=await Promise.all(e.map(o=>t(o||"",{nodir:!0})));return Array.from(new Set(n.flat()))};export{x as program};
2
+ import{Command as o}from"commander";import e from"chokidar";import{glob as t}from"glob";import{minimatch as n}from"minimatch";import i from"chalk";import{ensureConfig as a,loadConfig as r}from"./config.js";import{detectConfig as c}from"./heuristic-config.js";import{runExtractor as s}from"./extractor/core/extractor.js";import"node:path";import"node:fs/promises";import"jiti";import"@croct/json5-parser";import{runTypesGenerator as l}from"./types-generator.js";import{runSyncer as p}from"./syncer.js";import{runMigrator as f}from"./migrator.js";import{runInit as m}from"./init.js";import{runLinterCli as d}from"./linter.js";import{runStatus as g}from"./status.js";import{runLocizeSync as u,runLocizeDownload as y,runLocizeMigrate as h}from"./locize.js";import{runRenameKey as w}from"./rename-key.js";const x=new o;x.name("i18next-cli").description("A unified, high-performance i18next CLI.").version("1.31.0"),x.option("-c, --config <path>","Path to i18next-cli config file (overrides detection)"),x.command("extract").description("Extract translation keys from source files and update resource files.").option("-w, --watch","Watch for file changes and re-run the extractor.").option("--ci","Exit with a non-zero status code if any files are updated.").option("--dry-run","Run the extractor without writing any files to disk.").option("--sync-primary","Sync primary language values with default values from code.").option("--sync-all","Sync primary language values with default values from code AND clear synced keys in all other locales.").action(async o=>{try{const t=x.opts().config,i=await a(t),r=async()=>{const e=!!o.syncPrimary||!!o.syncAll,t=await s(i,{isWatchMode:!!o.watch,isDryRun:!!o.dryRun,syncPrimaryWithDefaults:e,syncAll:!!o.syncAll});return o.ci&&!t?(console.log("✅ No files were updated."),process.exit(0)):o.ci&&t&&(console.error("❌ Some files were updated. This should not happen in CI mode."),process.exit(1)),t};if(await r(),o.watch){console.log("\nWatching for changes...");const o=await v(i.extract.input),t=j(i.extract.ignore),a=k(i.extract.output),c=[...t,...a].filter(Boolean),s=o.filter(o=>!c.some(e=>n(o,e,{dot:!0})));e.watch(s,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}catch(o){console.error("Error running extractor:",o),process.exit(1)}}),x.command("status [locale]").description("Display translation status. Provide a locale for a detailed key-by-key view.").option("-n, --namespace <ns>","Filter the status report by a specific namespace").action(async(o,e)=>{const t=x.opts().config;let n=await r(t);if(!n){console.log(i.blue("No config file found. Attempting to detect project structure..."));const o=await c();o||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),n=o}await g(n,{detail:o,namespace:e.namespace})}),x.command("types").description("Generate TypeScript definitions from translation resource files.").option("-w, --watch","Watch for file changes and re-run the type generator.").action(async o=>{const t=x.opts().config,i=await a(t),r=()=>l(i);if(await r(),o.watch){console.log("\nWatching for changes...");const o=await v(i.types?.input||[]),t=[...j(i.extract?.ignore)].filter(Boolean),a=o.filter(o=>!t.some(e=>n(o,e,{dot:!0})));e.watch(a,{persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),r()})}}),x.command("sync").description("Synchronize secondary language files with the primary language file.").action(async()=>{const o=x.opts().config,e=await a(o);await p(e)}),x.command("migrate-config [configPath]").description("Migrate a legacy i18next-parser.config.js to the new format.").action(async o=>{await f(o)}),x.command("init").description("Create a new i18next.config.ts/js file with an interactive setup wizard.").action(m),x.command("lint").description("Find potential issues like hardcoded strings in your codebase.").option("-w, --watch","Watch for file changes and re-run the linter.").action(async o=>{const t=x.opts().config,a=async()=>{let o=await r(t);if(!o){console.log(i.blue("No config file found. Attempting to detect project structure..."));const e=await c();e||(console.error(i.red("Could not automatically detect your project structure.")),console.log(`Please create a config file first by running: ${i.cyan("npx i18next-cli init")}`),process.exit(1)),console.log(i.green("Project structure detected successfully!")),o=e}await d(o)};if(await a(),o.watch){console.log("\nWatching for changes...");const o=await r(t);if(o?.extract?.input){const t=await v(o.extract.input),i=[...j(o.extract.ignore),...k(o.extract.output)].filter(Boolean),r=t.filter(o=>!i.some(e=>n(o,e,{dot:!0})));e.watch(r,{ignored:/node_modules/,persistent:!0}).on("change",o=>{console.log(`\nFile changed: ${o}`),a()})}}}),x.command("locize-sync").description("Synchronize local translations with your locize project.").option("--update-values","Update values of existing translations on locize.").option("--src-lng-only","Check for changes in source language only.").option("--compare-mtime","Compare modification times when syncing.").option("--dry-run","Run the command without making any changes.").action(async o=>{const e=x.opts().config,t=await a(e);await u(t,o)}),x.command("locize-download").description("Download all translations from your locize project.").action(async o=>{const e=x.opts().config,t=await a(e);await y(t,o)}),x.command("locize-migrate").description("Migrate local translation files to a new locize project.").action(async o=>{const e=x.opts().config,t=await a(e);await h(t,o)}),x.command("rename-key <oldKey> <newKey>").description("Rename a translation key across all source files and translation files.").option("--dry-run","Preview changes without modifying files").action(async(o,e,t)=>{try{const n=x.opts().config,r=await a(n),c=await w(r,o,e,t);c.success||(c.conflicts&&(console.error(i.red("\n❌ Conflicts detected:")),c.conflicts.forEach(o=>console.error(` - ${o}`))),c.error&&console.error(i.red(`\n❌ ${c.error}`)),process.exit(1));0===c.sourceFiles.reduce((o,e)=>o+e.changes,0)&&console.log(i.yellow(`\n⚠️ No usages found for "${o}"`))}catch(o){console.error(i.red("Error renaming key:"),o),process.exit(1)}}),x.parse(process.argv);const j=o=>Array.isArray(o)?o:o?[o]:[],k=o=>o&&"string"==typeof o?[o.replace(/\{\{[^}]+\}\}/g,"*")]:[],v=async(o=[])=>{const e=j(o),n=await Promise.all(e.map(o=>t(o||"",{nodir:!0})));return Array.from(new Set(n.flat()))};export{x as program};
@@ -1 +1 @@
1
- import t from"ora";import a from"chalk";import{parse as e}from"@swc/core";import{mkdir as o,writeFile as r,readFile as n}from"node:fs/promises";import{dirname as s,extname as i}from"node:path";import{findKeys as c}from"./key-finder.js";import{getTranslations as l}from"./translation-manager.js";import{validateExtractorConfig as m,ExtractorError as p}from"../../utils/validation.js";import{extractKeysFromComments as f}from"../parsers/comment-parser.js";import{ConsoleLogger as u}from"../../utils/logger.js";import{loadRawJson5Content as y,serializeTranslationFile as d}from"../../utils/file-utils.js";import{shouldShowFunnel as g,recordFunnelShown as w}from"../../utils/funnel-msg-tracker.js";async function x(e,{isWatchMode:n=!1,isDryRun:i=!1,syncPrimaryWithDefaults:p=!1,syncAll:f=!1}={},x=new u){e.extract.primaryLanguage||=e.locales[0]||"en",e.extract.secondaryLanguages||=e.locales.filter(t=>t!==e?.extract?.primaryLanguage),e.extract.functions||=["t","*.t"],e.extract.transComponents||=["Trans"],m(e);const h=e.plugins||[],j=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:n}=await c(e,x);j.text=`Found ${t.size} unique keys. Updating translation files...`;const m=await l(t,n,e,{syncPrimaryWithDefaults:p,syncAll:f});let u=!1;for(const t of m)if(t.updated&&(u=!0,!i)){const n=e.extract.outputFormat??(t.path.endsWith(".json5")?"json5":"json"),i="json5"===n?await y(t.path)??void 0:void 0,c=d(t.newTranslations,n,e.extract.indentation,i);await o(s(t.path),{recursive:!0}),await r(t.path,c),x.info(a.green(`Updated: ${t.path}`))}if(h.length>0){j.text="Running post-extraction plugins...";for(const t of h)await(t.afterSync?.(m,e))}return j.succeed(a.bold("Extraction complete!")),u&&await async function(){if(!await g("extract"))return;return console.log(a.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${a.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${a.cyan("https://youtu.be/joPsZghT3wM")}`),w("extract")}(),u}catch(t){throw j.fail(a.red("Extraction failed.")),t}}async function h(t,o,r,s,c,l=new u){try{let a=await n(t,"utf-8");for(const e of o)try{const o=await(e.onLoad?.(a,t));void 0!==o&&(a=o)}catch(t){l.warn(`Plugin ${e.name} onLoad failed:`,t)}const m=i(t).toLowerCase(),u=".ts"===m||".tsx"===m||".mts"===m||".cts"===m,y=".tsx"===m,d=".jsx"===m;let g;try{g=await e(a,{syntax:u?"typescript":"ecmascript",tsx:y,jsx:d,decorators:!0,dynamicImport:!0,comments:!0})}catch(o){if(".ts"!==m||y){if(".js"!==m||d)throw new p("Failed to process file",t,o);try{g=await e(a,{syntax:"ecmascript",jsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),l.info?.(`Parsed ${t} using JSX fallback`)}catch(a){throw new p("Failed to process file",t,a)}}else try{g=await e(a,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),l.info?.(`Parsed ${t} using TSX fallback`)}catch(a){throw new p("Failed to process file",t,a)}}s.getVarFromScope=r.getVarFromScope.bind(r),r.setCurrentFile(t,a),r.visit(g),f(a,s,c,r.getVarFromScope.bind(r))}catch(e){l.warn(`${a.yellow("Skipping file due to error:")} ${t}`),l.warn(` ${e.message}`)}}async function j(t,{syncPrimaryWithDefaults:a=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(a=>a!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:e,objectKeys:o}=await c(t);return l(e,o,t,{syncPrimaryWithDefaults:a})}export{j as extract,h as processFile,x as runExtractor};
1
+ import t from"ora";import a from"chalk";import{parse as e}from"@swc/core";import{mkdir as o,writeFile as r,readFile as n}from"node:fs/promises";import{dirname as s,extname as i}from"node:path";import{findKeys as c}from"./key-finder.js";import{getTranslations as l}from"./translation-manager.js";import{validateExtractorConfig as m,ExtractorError as p}from"../../utils/validation.js";import{extractKeysFromComments as f}from"../parsers/comment-parser.js";import{ConsoleLogger as u}from"../../utils/logger.js";import{loadRawJson5Content as y,serializeTranslationFile as d}from"../../utils/file-utils.js";import{shouldShowFunnel as g,recordFunnelShown as w}from"../../utils/funnel-msg-tracker.js";async function x(e,{isWatchMode:n=!1,isDryRun:i=!1,syncPrimaryWithDefaults:p=!1,syncAll:f=!1}={},x=new u){e.extract.primaryLanguage||=e.locales[0]||"en",e.extract.secondaryLanguages||=e.locales.filter(t=>t!==e?.extract?.primaryLanguage),e.extract.functions||=["t","*.t"],e.extract.transComponents||=["Trans"],m(e);const h=e.plugins||[],j=t("Running i18next key extractor...\n").start();try{const{allKeys:t,objectKeys:n}=await c(e,x);j.text=`Found ${t.size} unique keys. Updating translation files...`;const m=await l(t,n,e,{syncPrimaryWithDefaults:p,syncAll:f});let u=!1;for(const t of m)if(t.updated&&(u=!0,!i)){const n=e.extract.outputFormat??(t.path.endsWith(".json5")?"json5":"json"),i="json5"===n?await y(t.path)??void 0:void 0,c=d(t.newTranslations,n,e.extract.indentation,i);await o(s(t.path),{recursive:!0}),await r(t.path,c),x.info(a.green(`Updated: ${t.path}`))}if(h.length>0){j.text="Running post-extraction plugins...";for(const t of h)await(t.afterSync?.(m,e))}return j.succeed(a.bold("Extraction complete!")),u&&await async function(){if(!await g("extract"))return;return console.log(a.yellow.bold("\n💡 Tip: Tired of running the extractor manually?")),console.log(' Discover a real-time "push" workflow with `saveMissing` and Locize AI,'),console.log(" where keys are created and translated automatically as you code."),console.log(` Learn more: ${a.cyan("https://www.locize.com/blog/i18next-savemissing-ai-automation")}`),console.log(` Watch the video: ${a.cyan("https://youtu.be/joPsZghT3wM")}`),w("extract")}(),u}catch(t){throw j.fail(a.red("Extraction failed.")),t}}async function h(t,o,r,s,c,l=new u){try{let a=await n(t,"utf-8");for(const e of o)try{const o=await(e.onLoad?.(a,t));void 0!==o&&(a=o)}catch(t){l.warn(`Plugin ${e.name} onLoad failed:`,t)}const m=i(t).toLowerCase(),u=".ts"===m||".tsx"===m||".mts"===m||".cts"===m,y=".tsx"===m,d=".jsx"===m;let g;try{g=await e(a,{syntax:u?"typescript":"ecmascript",tsx:y,jsx:d,decorators:!0,dynamicImport:!0,comments:!0})}catch(o){if(".ts"!==m||y){if(".js"!==m||d)throw new p("Failed to process file",t,o);try{g=await e(a,{syntax:"ecmascript",jsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),l.info?.(`Parsed ${t} using JSX fallback`)}catch(a){throw new p("Failed to process file",t,a)}}else try{g=await e(a,{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0,comments:!0}),l.info?.(`Parsed ${t} using TSX fallback`)}catch(a){throw new p("Failed to process file",t,a)}}s.getVarFromScope=r.getVarFromScope.bind(r),r.setCurrentFile(t,a),r.visit(g),!1!==c.extract.extractFromComments&&f(a,s,c,r.getVarFromScope.bind(r))}catch(e){l.warn(`${a.yellow("Skipping file due to error:")} ${t}`),l.warn(` ${e.message}`)}}async function j(t,{syncPrimaryWithDefaults:a=!1}={}){t.extract.primaryLanguage||=t.locales[0]||"en",t.extract.secondaryLanguages||=t.locales.filter(a=>a!==t?.extract?.primaryLanguage),t.extract.functions||=["t","*.t"],t.extract.transComponents||=["Trans"];const{allKeys:e,objectKeys:o}=await c(t);return l(e,o,t,{syncPrimaryWithDefaults:a})}export{j as extract,h as processFile,x as runExtractor};
@@ -1 +1 @@
1
- import{extractFromTransComponent as e}from"./jsx-parser.js";import{getObjectPropValue as t}from"./ast-utils.js";class n{config;pluginContext;expressionResolver;getCurrentFile;getCurrentCode;lastSearchIndex=0;constructor(e,t,n,i,o){this.config=e,this.pluginContext=t,this.expressionResolver=n,this.getCurrentFile=i,this.getCurrentCode=o}resetSearchIndex(){this.lastSearchIndex=0}getLocationFromNode(e){const t=this.getCurrentCode();let n;if("JSXElement"===e.type&&e.opening){const t=e.opening.name?.value;t&&(n=`<${t}`)}if(!n)return;const i=t.indexOf(n,this.lastSearchIndex);if(-1===i)return;this.lastSearchIndex=i+n.length;const o=t.substring(0,i).split("\n");return{line:o.length,column:o[o.length-1].length}}handleJSXElement(t,n){const i=this.getElementName(t);if(i&&(this.config.extract.transComponents||["Trans"]).includes(i)){const i=e(t,this.config),o=[];if(i){if(i.keyExpression){const e=this.expressionResolver.resolvePossibleKeyStringValues(i.keyExpression);o.push(...e)}else o.push(i.serializedChildren);let e;const{contextExpression:s,optionsNode:a,defaultValue:l,hasCount:r,isOrdinal:u,serializedChildren:f}=i,c=this.getLocationFromNode(t),d=c?[{file:this.getCurrentFile(),line:c.line,column:c.column}]:void 0;if(i.ns){const{ns:t}=i;e=o.map(e=>({key:e,ns:t,defaultValue:l||f,hasCount:r,isOrdinal:u,locations:d}))}else{e=o.map(e=>{const t=this.config.extract.nsSeparator??":";let n;if(t&&e.includes(t)){let i;[n,...i]=e.split(t),e=i.join(t)}return{key:e,ns:n,defaultValue:l||f,hasCount:r,isOrdinal:u,explicitDefault:i.explicitDefault,locations:d}});const s=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"t"===e.name.value);if("JSXAttribute"===s?.type&&"JSXExpressionContainer"===s.value?.type&&"Identifier"===s.value.expression.type){const t=n(s.value.expression.value);if(t?.defaultNs&&e.forEach(e=>{e.ns||(e.ns=t.defaultNs)}),t?.keyPrefix){const n=this.config.extract.keySeparator??".";for(const i of e){let e=i.key;if(e=!1!==n?String(t.keyPrefix).endsWith(String(n))?`${t.keyPrefix}${e}`:`${t.keyPrefix}${n}${e}`:`${t.keyPrefix}${e}`,!1!==n){if(String(e).split(String(n)).some(e=>""===e.trim()))continue}i.key=e}}}}if(e.forEach(e=>{e.ns||(e.ns=this.config.extract.defaultNS)}),s&&r)if(this.config.extract.disablePlurals){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0)if("StringLiteral"===s.type)for(const i of t)for(const t of e){const e=`${t.key}${n}${i}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}else{e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})});for(const i of t)for(const t of e){const e=`${t.key}${n}${i}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),i=!!n,o=this.expressionResolver.resolvePossibleContextStringValues(s),l=this.config.extract.contextSeparator??"_";if(o.length>0){e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,void 0,e.locations,e.key));for(const t of o)for(const n of e){const e=`${n.key}${l}${t}`;this.generatePluralKeysForTrans(e,n.defaultValue,n.ns,i,a,n.explicitDefault,n.locations,n.key)}}else e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,e.explicitDefault,e.locations))}else if(s){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0){for(const i of t)for(const{key:t,ns:o,defaultValue:s,locations:a}of e)this.pluginContext.addKey({key:`${t}${n}${i}`,ns:o,defaultValue:s,locations:a});"StringLiteral"!==s.type&&e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else if(r)if(this.config.extract.disablePlurals)e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})});else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),i=!!n;e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,e.explicitDefault,e.locations))}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})})}}}generatePluralKeysForTrans(e,n,i,o,s,a,l,r){try{const u=o?"ordinal":"cardinal",f=new Intl.PluralRules(this.config.extract?.primaryLanguage,{type:u}).resolvedOptions().pluralCategories,c=this.config.extract.pluralSeparator??"_";let d,p;if(s&&(d=t(s,`defaultValue${c}other`),p=t(s,`defaultValue${c}ordinal${c}other`)),1===f.length&&"other"===f[0]){const u=s?t(s,`defaultValue${c}other`):void 0,f="string"==typeof u?u:"string"==typeof n?n:e;return void this.pluginContext.addKey({key:e,ns:i,defaultValue:f,hasCount:!0,isOrdinal:o,explicitDefault:Boolean(a||"string"==typeof u||"string"==typeof d),locations:l,keyAcceptingContext:r})}for(const u of f){const f=s?t(s,o?`defaultValue${c}ordinal${c}${u}`:`defaultValue${c}${u}`):void 0;let y;y="string"==typeof f?f:"one"===u&&"string"==typeof n?n:o&&"string"==typeof p?p:o||"string"!=typeof d?"string"==typeof n?n:e:d;const g=o?`${e}${c}ordinal${c}${u}`:`${e}${c}${u}`;this.pluginContext.addKey({key:g,ns:i,defaultValue:y,hasCount:!0,isOrdinal:o,explicitDefault:Boolean(a||"string"==typeof f||"string"==typeof d),locations:l,keyAcceptingContext:r})}}catch(t){this.pluginContext.addKey({key:e,ns:i,defaultValue:n,locations:l})}}getElementName(e){if("Identifier"===e.opening.name.type)return e.opening.name.value;if("JSXMemberExpression"===e.opening.name.type){let t=e.opening.name;const n=[];for(;"JSXMemberExpression"===t.type;)"Identifier"===t.property.type&&n.unshift(t.property.value),t=t.object;return"Identifier"===t.type&&n.unshift(t.value),n.join(".")}}}export{n as JSXHandler};
1
+ import{extractFromTransComponent as e}from"./jsx-parser.js";import{getObjectPropValue as t}from"./ast-utils.js";class n{config;pluginContext;expressionResolver;getCurrentFile;getCurrentCode;lastSearchIndex=0;constructor(e,t,n,i,o){this.config=e,this.pluginContext=t,this.expressionResolver=n,this.getCurrentFile=i,this.getCurrentCode=o}resetSearchIndex(){this.lastSearchIndex=0}getLocationFromNode(e){const t=this.getCurrentCode();let n;if("JSXElement"===e.type&&e.opening){const t=e.opening.name?.value;t&&(n=`<${t}`)}if(!n)return;const i=t.indexOf(n,this.lastSearchIndex);if(-1===i)return;this.lastSearchIndex=i+n.length;const o=t.substring(0,i).split("\n");return{line:o.length,column:o[o.length-1].length}}handleJSXElement(t,n){const i=this.getElementName(t);if(i&&(this.config.extract.transComponents||["Trans"]).includes(i)){const i=e(t,this.config),o=[];if(i){if(i.keyExpression){const e=this.expressionResolver.resolvePossibleKeyStringValues(i.keyExpression);o.push(...e)}else o.push(i.serializedChildren);let e;const{contextExpression:s,optionsNode:a,defaultValue:l,hasCount:r,isOrdinal:u,serializedChildren:f}=i,c=this.getLocationFromNode(t),d=c?[{file:this.getCurrentFile(),line:c.line,column:c.column}]:void 0;if(i.ns){const{ns:t}=i;e=o.map(e=>({key:e,ns:t,defaultValue:l||f,hasCount:r,isOrdinal:u,locations:d}))}else{e=o.map(e=>{const t=this.config.extract.nsSeparator??":";let n;if(t&&e.includes(t)){let i;[n,...i]=e.split(t),e=i.join(t)}return{key:e,ns:n,defaultValue:l||f,hasCount:r,isOrdinal:u,explicitDefault:i.explicitDefault,locations:d}});const s=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"t"===e.name.value);if("JSXAttribute"===s?.type&&"JSXExpressionContainer"===s.value?.type&&"Identifier"===s.value.expression.type){const t=n(s.value.expression.value);if(t?.defaultNs&&e.forEach(e=>{e.ns||(e.ns=t.defaultNs)}),t?.keyPrefix){const n=this.config.extract.keySeparator??".";for(const i of e){let e=i.key;if(e=!1!==n?String(t.keyPrefix).endsWith(String(n))?`${t.keyPrefix}${e}`:`${t.keyPrefix}${n}${e}`:`${t.keyPrefix}${e}`,!1!==n){if(String(e).split(String(n)).some(e=>""===e.trim()))continue}i.key=e}}}}if(e.forEach(e=>{e.ns||(e.ns=this.config.extract.defaultNS)}),s&&r)if(this.config.extract.disablePlurals){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0)if("StringLiteral"===s.type)for(const i of t)for(const t of e){const e=`${t.key}${n}${i}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}else{e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})});for(const i of t)for(const t of e){const e=`${t.key}${n}${i}`;this.pluginContext.addKey({key:e,ns:t.ns,defaultValue:t.defaultValue,locations:t.locations})}}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),i=!!n,o=this.expressionResolver.resolvePossibleContextStringValues(s),l=this.config.extract.contextSeparator??"_";if(o.length>0){!1!==this.config.extract.generateBasePluralForms&&e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,void 0,e.locations,e.key));for(const t of o)for(const n of e){const e=`${n.key}${l}${t}`;this.generatePluralKeysForTrans(e,n.defaultValue,n.ns,i,a,n.explicitDefault,n.locations,n.key)}}else e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,e.explicitDefault,e.locations))}else if(s){const t=this.expressionResolver.resolvePossibleContextStringValues(s),n=this.config.extract.contextSeparator??"_";if(t.length>0){for(const i of t)for(const{key:t,ns:o,defaultValue:s,locations:a}of e)this.pluginContext.addKey({key:`${t}${n}${i}`,ns:o,defaultValue:s,locations:a});"StringLiteral"!==s.type&&e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations,keyAcceptingContext:e.key})})}else if(r)if(this.config.extract.disablePlurals)e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})});else{const n=t.opening.attributes?.find(e=>"JSXAttribute"===e.type&&"Identifier"===e.name.type&&"ordinal"===e.name.value),i=!!n;e.forEach(e=>this.generatePluralKeysForTrans(e.key,e.defaultValue,e.ns,i,a,e.explicitDefault,e.locations))}else e.forEach(e=>{this.pluginContext.addKey({key:e.key,ns:e.ns,defaultValue:e.defaultValue,locations:e.locations})})}}}generatePluralKeysForTrans(e,n,i,o,s,a,l,r){try{const u=o?"ordinal":"cardinal",f=new Intl.PluralRules(this.config.extract?.primaryLanguage,{type:u}).resolvedOptions().pluralCategories,c=this.config.extract.pluralSeparator??"_";let d,p;if(s&&(d=t(s,`defaultValue${c}other`),p=t(s,`defaultValue${c}ordinal${c}other`)),1===f.length&&"other"===f[0]){const u=s?t(s,`defaultValue${c}other`):void 0,f="string"==typeof u?u:"string"==typeof n?n:e;return void this.pluginContext.addKey({key:e,ns:i,defaultValue:f,hasCount:!0,isOrdinal:o,explicitDefault:Boolean(a||"string"==typeof u||"string"==typeof d),locations:l,keyAcceptingContext:r})}for(const u of f){const f=s?t(s,o?`defaultValue${c}ordinal${c}${u}`:`defaultValue${c}${u}`):void 0;let y;y="string"==typeof f?f:"one"===u&&"string"==typeof n?n:o&&"string"==typeof p?p:o||"string"!=typeof d?"string"==typeof n?n:e:d;const g=o?`${e}${c}ordinal${c}${u}`:`${e}${c}${u}`;this.pluginContext.addKey({key:g,ns:i,defaultValue:y,hasCount:!0,isOrdinal:o,explicitDefault:Boolean(a||"string"==typeof f||"string"==typeof d),locations:l,keyAcceptingContext:r})}}catch(t){this.pluginContext.addKey({key:e,ns:i,defaultValue:n,locations:l})}}getElementName(e){if("Identifier"===e.opening.name.type)return e.opening.name.value;if("JSXMemberExpression"===e.opening.name.type){let t=e.opening.name;const n=[];for(;"JSXMemberExpression"===t.type;)"Identifier"===t.property.type&&n.unshift(t.property.value),t=t.object;return"Identifier"===t.type&&n.unshift(t.value),n.join(".")}}}export{n as JSXHandler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18next-cli",
3
- "version": "1.30.5",
3
+ "version": "1.31.0",
4
4
  "description": "A unified, high-performance i18next CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAKtF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAK5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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AM,KAAK;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,IAAI;IA+SjI;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,0BAA0B;IAqGlC;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;CAevB"}
package/types/types.d.ts CHANGED
@@ -117,6 +117,11 @@ export interface I18nextToolkitConfig {
117
117
  mergeNamespaces?: boolean;
118
118
  /** If true, keys that are not found in the source code will be removed from translation files. (default: true) */
119
119
  removeUnusedKeys?: boolean;
120
+ /**
121
+ * If false, translation keys will not be extracted from comments.
122
+ * (default: true)
123
+ */
124
+ extractFromComments?: boolean;
120
125
  generateBasePluralForms?: boolean;
121
126
  disablePlurals?: boolean;
122
127
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,2DAA2D;IAC3D,OAAO,EAAE;QACP,oEAAoE;QACpE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAEzB,4DAA4D;QAC5D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAE3B,mGAAmG;QACnG,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;QAEpE;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;QAE3B,uEAAuE;QACvE,YAAY,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;QAErC,8EAA8E;QAC9E,WA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