i18next-cli 1.51.1 → 1.51.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/README.md +2 -2
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/core/extractor.js +8 -0
- package/dist/cjs/extractor/core/translation-manager.js +5 -2
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/core/extractor.js +9 -1
- package/dist/esm/extractor/core/translation-manager.js +5 -2
- package/package.json +1 -1
- package/types/extractor/core/extractor.d.ts.map +1 -1
- package/types/extractor/core/translation-manager.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -683,10 +683,10 @@ export default defineConfig({
|
|
|
683
683
|
// options for linter
|
|
684
684
|
lint: {
|
|
685
685
|
/** Optional accept-list of JSX attribute names to exclusively lint (takes precedence over ignoredAttributes). */
|
|
686
|
-
acceptedAttributes: ['title']
|
|
686
|
+
acceptedAttributes: ['title'],
|
|
687
687
|
|
|
688
688
|
/** Optional accept-list of JSX tag names to exclusively lint (takes precedence over ignoredTags). */
|
|
689
|
-
acceptedTags: ['p']
|
|
689
|
+
acceptedTags: ['p'],
|
|
690
690
|
|
|
691
691
|
// Optional custom JSX attributes to ignore during linting
|
|
692
692
|
ignoredAttributes: ['data-testid', 'aria-label'],
|
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.51.
|
|
34
|
+
.version('1.51.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
|
|
@@ -149,6 +149,10 @@ function isExtExplicitlyInInputPatterns(ext, input) {
|
|
|
149
149
|
*/
|
|
150
150
|
async function processFile(file, plugins, astVisitors, pluginContext, config, logger$1 = new logger.ConsoleLogger(), fileErrors) {
|
|
151
151
|
try {
|
|
152
|
+
// Skip directories that happen to match file-extension globs (e.g. a directory named "Foo.tsx")
|
|
153
|
+
const fileStat = await promises.stat(file);
|
|
154
|
+
if (fileStat.isDirectory())
|
|
155
|
+
return;
|
|
152
156
|
let code = await promises.readFile(file, 'utf-8');
|
|
153
157
|
// Run onLoad hooks from plugins with error handling.
|
|
154
158
|
// Track whether any plugin actually transformed the code so we can make
|
|
@@ -302,6 +306,10 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
|
|
|
302
306
|
*/
|
|
303
307
|
async function preScanFile(file, astVisitors, config, logger$1 = new logger.ConsoleLogger(), fileErrors) {
|
|
304
308
|
try {
|
|
309
|
+
// Skip directories that happen to match file-extension globs (e.g. a directory named "Foo.tsx")
|
|
310
|
+
const fileStat = await promises.stat(file);
|
|
311
|
+
if (fileStat.isDirectory())
|
|
312
|
+
return;
|
|
305
313
|
const code = await promises.readFile(file, 'utf-8');
|
|
306
314
|
const fileExt = node_path.extname(file).toLowerCase();
|
|
307
315
|
// Non-native files (e.g. .svelte, .vue) cannot be parsed by SWC in the
|
|
@@ -915,9 +915,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
915
915
|
}
|
|
916
916
|
// When nsSeparator is false, keys resolved to the defaultNS (e.g. from
|
|
917
917
|
// useTranslation() with no args) should be treated as top-level, not
|
|
918
|
-
// wrapped under the namespace name
|
|
918
|
+
// wrapped under the namespace name — but only when there are no other
|
|
919
|
+
// explicit namespaces. If multiple namespaces exist, we must keep the
|
|
920
|
+
// default namespace wrapper to avoid flattening it into the top level (#227).
|
|
919
921
|
const defaultNs = String(config.extract.defaultNS ?? 'translation');
|
|
920
|
-
const
|
|
922
|
+
const hasOtherNamespaces = [...keysByNS.keys()].some(k => k !== NO_NS_TOKEN && k !== defaultNs);
|
|
923
|
+
const isTopLevel = (nsKey) => nsKey === NO_NS_TOKEN || (config.extract.nsSeparator === false && nsKey === defaultNs && !hasOtherNamespaces);
|
|
921
924
|
for (const nsKey of namespacesToProcess) {
|
|
922
925
|
const nsKeys = keysByNS.get(nsKey) || [];
|
|
923
926
|
if (isTopLevel(nsKey)) {
|
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.51.
|
|
32
|
+
.version('1.51.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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSpinnerLike } from '../../utils/wrap-ora.js';
|
|
2
2
|
import { styleText } from 'node:util';
|
|
3
3
|
import { parse } from '@swc/core';
|
|
4
|
-
import { mkdir, writeFile, readFile } from 'node:fs/promises';
|
|
4
|
+
import { mkdir, writeFile, stat, readFile } from 'node:fs/promises';
|
|
5
5
|
import { dirname, extname } from 'node:path';
|
|
6
6
|
import { findKeys } from './key-finder.js';
|
|
7
7
|
import { getTranslations } from './translation-manager.js';
|
|
@@ -147,6 +147,10 @@ function isExtExplicitlyInInputPatterns(ext, input) {
|
|
|
147
147
|
*/
|
|
148
148
|
async function processFile(file, plugins, astVisitors, pluginContext, config, logger = new ConsoleLogger(), fileErrors) {
|
|
149
149
|
try {
|
|
150
|
+
// Skip directories that happen to match file-extension globs (e.g. a directory named "Foo.tsx")
|
|
151
|
+
const fileStat = await stat(file);
|
|
152
|
+
if (fileStat.isDirectory())
|
|
153
|
+
return;
|
|
150
154
|
let code = await readFile(file, 'utf-8');
|
|
151
155
|
// Run onLoad hooks from plugins with error handling.
|
|
152
156
|
// Track whether any plugin actually transformed the code so we can make
|
|
@@ -300,6 +304,10 @@ async function processFile(file, plugins, astVisitors, pluginContext, config, lo
|
|
|
300
304
|
*/
|
|
301
305
|
async function preScanFile(file, astVisitors, config, logger = new ConsoleLogger(), fileErrors) {
|
|
302
306
|
try {
|
|
307
|
+
// Skip directories that happen to match file-extension globs (e.g. a directory named "Foo.tsx")
|
|
308
|
+
const fileStat = await stat(file);
|
|
309
|
+
if (fileStat.isDirectory())
|
|
310
|
+
return;
|
|
303
311
|
const code = await readFile(file, 'utf-8');
|
|
304
312
|
const fileExt = extname(file).toLowerCase();
|
|
305
313
|
// Non-native files (e.g. .svelte, .vue) cannot be parsed by SWC in the
|
|
@@ -913,9 +913,12 @@ async function getTranslations(keys, objectKeys, config, { syncPrimaryWithDefaul
|
|
|
913
913
|
}
|
|
914
914
|
// When nsSeparator is false, keys resolved to the defaultNS (e.g. from
|
|
915
915
|
// useTranslation() with no args) should be treated as top-level, not
|
|
916
|
-
// wrapped under the namespace name
|
|
916
|
+
// wrapped under the namespace name — but only when there are no other
|
|
917
|
+
// explicit namespaces. If multiple namespaces exist, we must keep the
|
|
918
|
+
// default namespace wrapper to avoid flattening it into the top level (#227).
|
|
917
919
|
const defaultNs = String(config.extract.defaultNS ?? 'translation');
|
|
918
|
-
const
|
|
920
|
+
const hasOtherNamespaces = [...keysByNS.keys()].some(k => k !== NO_NS_TOKEN && k !== defaultNs);
|
|
921
|
+
const isTopLevel = (nsKey) => nsKey === NO_NS_TOKEN || (config.extract.nsSeparator === false && nsKey === defaultNs && !hasOtherNamespaces);
|
|
919
922
|
for (const nsKey of namespacesToProcess) {
|
|
920
923
|
const nsKeys = keysByNS.get(nsKey) || [];
|
|
921
924
|
if (isTopLevel(nsKey)) {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../../src/extractor/core/extractor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAO5G,OAAO,EAAE,WAAW,EAA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ClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GACL,OAAO,CAAC;IAAE,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CA6E1D;AAwBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CAoJf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAC7C,MAAM,GAAE,MAA4B,EACpC,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,OAAO,CAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,uBAA+B,EAAE,GAAE;IAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAO1K"}
|
|
@@ -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;AA66B9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
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;AA66B9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAuJ9B"}
|