i18next-cli 0.9.18 → 0.9.20
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/CHANGELOG.md +10 -2
- package/README.md +15 -0
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/extractor/parsers/ast-utils.js +1 -0
- package/dist/cjs/extractor/parsers/ast-visitors.js +1 -1
- package/dist/cjs/extractor/parsers/jsx-parser.js +1 -1
- package/dist/cjs/locize.js +1 -1
- package/dist/cjs/status.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/extractor/parsers/ast-utils.js +1 -0
- package/dist/esm/extractor/parsers/ast-visitors.js +1 -1
- package/dist/esm/extractor/parsers/jsx-parser.js +1 -1
- package/dist/esm/locize.js +1 -1
- package/dist/esm/status.js +1 -1
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/extractor/parsers/ast-utils.ts +52 -0
- package/src/extractor/parsers/ast-visitors.ts +78 -101
- package/src/extractor/parsers/jsx-parser.ts +34 -9
- package/src/locize.ts +38 -57
- package/src/status.ts +43 -28
- package/src/types.ts +7 -1
- package/types/extractor/parsers/ast-utils.d.ts +31 -0
- package/types/extractor/parsers/ast-utils.d.ts.map +1 -0
- package/types/extractor/parsers/ast-visitors.d.ts +1 -29
- package/types/extractor/parsers/ast-visitors.d.ts.map +1 -1
- package/types/extractor/parsers/jsx-parser.d.ts.map +1 -1
- package/types/locize.d.ts.map +1 -1
- package/types/status.d.ts.map +1 -1
- package/types/types.d.ts +5 -1
- package/types/types.d.ts.map +1 -1
- package/vitest.config.ts +4 -0
- package/tryme.js +0 -8
package/src/status.ts
CHANGED
|
@@ -21,11 +21,13 @@ interface StatusOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
interface StatusReport {
|
|
23
23
|
/** Total number of extracted keys across all namespaces */
|
|
24
|
-
|
|
24
|
+
totalBaseKeys: number;
|
|
25
25
|
/** Map of namespace names to their extracted keys */
|
|
26
26
|
keysByNs: Map<string, ExtractedKey[]>;
|
|
27
27
|
/** Map of locale codes to their translation status data */
|
|
28
28
|
locales: Map<string, {
|
|
29
|
+
/** Total number of extracted keys per locale */
|
|
30
|
+
totalKeys: number;
|
|
29
31
|
/** Total number of translated keys for this locale */
|
|
30
32
|
totalTranslated: number;
|
|
31
33
|
/** Map of namespace names to their translation details for this locale */
|
|
@@ -87,12 +89,7 @@ async function generateStatusReport (config: I18nextToolkitConfig): Promise<Stat
|
|
|
87
89
|
config.extract.secondaryLanguages ||= config.locales.filter((l: string) => l !== config?.extract?.primaryLanguage)
|
|
88
90
|
|
|
89
91
|
const { allKeys: allExtractedKeys } = await findKeys(config)
|
|
90
|
-
const {
|
|
91
|
-
secondaryLanguages,
|
|
92
|
-
keySeparator = '.',
|
|
93
|
-
defaultNS = 'translation',
|
|
94
|
-
mergeNamespaces = false,
|
|
95
|
-
} = config.extract
|
|
92
|
+
const { secondaryLanguages, keySeparator = '.', defaultNS = 'translation', mergeNamespaces = false, pluralSeparator = '_' } = config.extract
|
|
96
93
|
|
|
97
94
|
const keysByNs = new Map<string, ExtractedKey[]>()
|
|
98
95
|
for (const key of allExtractedKeys.values()) {
|
|
@@ -102,13 +99,14 @@ async function generateStatusReport (config: I18nextToolkitConfig): Promise<Stat
|
|
|
102
99
|
}
|
|
103
100
|
|
|
104
101
|
const report: StatusReport = {
|
|
105
|
-
|
|
102
|
+
totalBaseKeys: allExtractedKeys.size,
|
|
106
103
|
keysByNs,
|
|
107
104
|
locales: new Map(),
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
for (const locale of secondaryLanguages) {
|
|
111
108
|
let totalTranslatedForLocale = 0
|
|
109
|
+
let totalKeysForLocale = 0
|
|
112
110
|
const namespaces = new Map<string, any>()
|
|
113
111
|
|
|
114
112
|
const mergedTranslations = mergeNamespaces
|
|
@@ -121,24 +119,41 @@ async function generateStatusReport (config: I18nextToolkitConfig): Promise<Stat
|
|
|
121
119
|
: await loadTranslationFile(resolve(process.cwd(), getOutputPath(config.extract.output, locale, ns))) || {}
|
|
122
120
|
|
|
123
121
|
let translatedInNs = 0
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
122
|
+
let totalInNs = 0
|
|
123
|
+
const keyDetails: Array<{ key: string; isTranslated: boolean }> = []
|
|
124
|
+
|
|
125
|
+
// This is the new, language-aware logic loop
|
|
126
|
+
for (const { key: baseKey, hasCount, isOrdinal } of keysInNs) {
|
|
127
|
+
if (hasCount) {
|
|
128
|
+
const type = isOrdinal ? 'ordinal' : 'cardinal'
|
|
129
|
+
// It's a plural key: expand it based on the current locale's rules
|
|
130
|
+
const pluralCategories = new Intl.PluralRules(locale, { type }).resolvedOptions().pluralCategories
|
|
131
|
+
for (const category of pluralCategories) {
|
|
132
|
+
totalInNs++
|
|
133
|
+
const pluralKey = isOrdinal
|
|
134
|
+
? `${baseKey}${pluralSeparator}ordinal${pluralSeparator}${category}`
|
|
135
|
+
: `${baseKey}${pluralSeparator}${category}`
|
|
136
|
+
const value = getNestedValue(translationsForNs, pluralKey, keySeparator ?? '.')
|
|
137
|
+
const isTranslated = !!value
|
|
138
|
+
if (isTranslated) translatedInNs++
|
|
139
|
+
keyDetails.push({ key: pluralKey, isTranslated })
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
// It's a simple key
|
|
143
|
+
totalInNs++
|
|
144
|
+
const value = getNestedValue(translationsForNs, baseKey, keySeparator ?? '.')
|
|
145
|
+
const isTranslated = !!value
|
|
146
|
+
if (isTranslated) translatedInNs++
|
|
147
|
+
keyDetails.push({ key: baseKey, isTranslated })
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
namespaces.set(ns, { totalKeys: totalInNs, translatedKeys: translatedInNs, keyDetails })
|
|
137
152
|
totalTranslatedForLocale += translatedInNs
|
|
153
|
+
totalKeysForLocale += totalInNs
|
|
138
154
|
}
|
|
139
|
-
report.locales.set(locale, { totalTranslated: totalTranslatedForLocale, namespaces })
|
|
155
|
+
report.locales.set(locale, { totalKeys: totalKeysForLocale, totalTranslated: totalTranslatedForLocale, namespaces })
|
|
140
156
|
}
|
|
141
|
-
|
|
142
157
|
return report
|
|
143
158
|
}
|
|
144
159
|
|
|
@@ -198,7 +213,7 @@ function displayDetailedLocaleReport (report: StatusReport, config: I18nextToolk
|
|
|
198
213
|
console.log(chalk.bold(`\nKey Status for "${chalk.cyan(locale)}":`))
|
|
199
214
|
|
|
200
215
|
const totalKeysForLocale = Array.from(report.keysByNs.values()).flat().length
|
|
201
|
-
printProgressBar('Overall', localeData.totalTranslated,
|
|
216
|
+
printProgressBar('Overall', localeData.totalTranslated, localeData.totalKeys)
|
|
202
217
|
|
|
203
218
|
const namespacesToDisplay = namespaceFilter ? [namespaceFilter] : Array.from(localeData.namespaces.keys()).sort()
|
|
204
219
|
|
|
@@ -273,16 +288,16 @@ function displayOverallSummaryReport (report: StatusReport, config: I18nextToolk
|
|
|
273
288
|
|
|
274
289
|
console.log(chalk.cyan.bold('\ni18next Project Status'))
|
|
275
290
|
console.log('------------------------')
|
|
276
|
-
console.log(`🔑 Keys Found: ${chalk.bold(report.
|
|
291
|
+
console.log(`🔑 Keys Found: ${chalk.bold(report.totalBaseKeys)}`)
|
|
277
292
|
console.log(`📚 Namespaces Found: ${chalk.bold(report.keysByNs.size)}`)
|
|
278
293
|
console.log(`🌍 Locales: ${chalk.bold(config.locales.join(', '))}`)
|
|
279
294
|
console.log(`✅ Primary Language: ${chalk.bold(primaryLanguage)}`)
|
|
280
295
|
console.log('\nTranslation Progress:')
|
|
281
296
|
|
|
282
297
|
for (const [locale, localeData] of report.locales.entries()) {
|
|
283
|
-
const percentage =
|
|
298
|
+
const percentage = localeData.totalKeys > 0 ? Math.round((localeData.totalTranslated / localeData.totalKeys) * 100) : 100
|
|
284
299
|
const bar = generateProgressBarText(percentage)
|
|
285
|
-
console.log(`- ${locale}: ${bar} ${percentage}% (${localeData.totalTranslated}/${
|
|
300
|
+
console.log(`- ${locale}: ${bar} ${percentage}% (${localeData.totalTranslated}/${localeData.totalKeys} keys)`)
|
|
286
301
|
}
|
|
287
302
|
|
|
288
303
|
printLocizeFunnel()
|
|
@@ -312,7 +327,7 @@ function printProgressBar (label: string, current: number, total: number) {
|
|
|
312
327
|
*/
|
|
313
328
|
function generateProgressBarText (percentage: number): string {
|
|
314
329
|
const totalBars = 20
|
|
315
|
-
const filledBars = Math.
|
|
330
|
+
const filledBars = Math.floor((percentage / 100) * totalBars)
|
|
316
331
|
const emptyBars = totalBars - filledBars
|
|
317
332
|
return `[${chalk.green(''.padStart(filledBars, '■'))}${''.padStart(emptyBars, '□')}]`
|
|
318
333
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Expression } from '@swc/core'
|
|
1
|
+
import type { Node, Expression, ObjectExpression } from '@swc/core'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Main configuration interface for the i18next toolkit.
|
|
@@ -251,6 +251,12 @@ export interface ExtractedKey {
|
|
|
251
251
|
/** Whether this key is used with pluralization (count parameter) */
|
|
252
252
|
hasCount?: boolean;
|
|
253
253
|
|
|
254
|
+
/** Whether this key is used with ordinal pluralization */
|
|
255
|
+
isOrdinal?: boolean;
|
|
256
|
+
|
|
257
|
+
/** AST node for options object, used for advanced plural handling in Trans */
|
|
258
|
+
optionsNode?: ObjectExpression;
|
|
259
|
+
|
|
254
260
|
/** hold the raw context expression from the AST */
|
|
255
261
|
contextExpression?: Expression;
|
|
256
262
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ObjectExpression } from '@swc/core';
|
|
2
|
+
/**
|
|
3
|
+
* Finds and returns the full property node (KeyValueProperty) for the given
|
|
4
|
+
* property name from an ObjectExpression.
|
|
5
|
+
*
|
|
6
|
+
* Matches both identifier keys (e.g., { ns: 'value' }) and string literal keys
|
|
7
|
+
* (e.g., { 'ns': 'value' }).
|
|
8
|
+
*
|
|
9
|
+
* This helper returns the full property node rather than just its primitive
|
|
10
|
+
* value so callers can inspect expression types (ConditionalExpression, etc.).
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
* @param object - The SWC ObjectExpression to search
|
|
14
|
+
* @param propName - The property name to locate
|
|
15
|
+
* @returns The matching KeyValueProperty node if found, otherwise undefined.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getObjectProperty(object: ObjectExpression, propName: string): any;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts string value from object property.
|
|
20
|
+
*
|
|
21
|
+
* Looks for properties by name and returns their string values.
|
|
22
|
+
* Used for extracting options like 'ns', 'defaultValue', 'context', etc.
|
|
23
|
+
*
|
|
24
|
+
* @param object - Object expression to search
|
|
25
|
+
* @param propName - Property name to find
|
|
26
|
+
* @returns String value if found, empty string if property exists but isn't a string, undefined if not found
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
export declare function getObjectPropValue(object: ObjectExpression, propName: string): string | boolean | number | undefined;
|
|
31
|
+
//# sourceMappingURL=ast-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAEjD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,CASlF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAWrH"}
|
|
@@ -162,6 +162,7 @@ export declare class ASTVisitors {
|
|
|
162
162
|
* @param key - Base key name for pluralization
|
|
163
163
|
* @param ns - Namespace for the keys
|
|
164
164
|
* @param options - object expression options
|
|
165
|
+
* @param isOrdinal - isOrdinal flag
|
|
165
166
|
*
|
|
166
167
|
* @private
|
|
167
168
|
*/
|
|
@@ -200,19 +201,6 @@ export declare class ASTVisitors {
|
|
|
200
201
|
* @private
|
|
201
202
|
*/
|
|
202
203
|
private getElementName;
|
|
203
|
-
/**
|
|
204
|
-
* Extracts string value from object property.
|
|
205
|
-
*
|
|
206
|
-
* Looks for properties by name and returns their string values.
|
|
207
|
-
* Used for extracting options like 'ns', 'defaultValue', 'context', etc.
|
|
208
|
-
*
|
|
209
|
-
* @param object - Object expression to search
|
|
210
|
-
* @param propName - Property name to find
|
|
211
|
-
* @returns String value if found, empty string if property exists but isn't a string, undefined if not found
|
|
212
|
-
*
|
|
213
|
-
* @private
|
|
214
|
-
*/
|
|
215
|
-
private getObjectPropValue;
|
|
216
204
|
/**
|
|
217
205
|
* Extracts translation key from selector API arrow function.
|
|
218
206
|
*
|
|
@@ -247,22 +235,6 @@ export declare class ASTVisitors {
|
|
|
247
235
|
* @returns An array of possible string values that the expression may produce.
|
|
248
236
|
*/
|
|
249
237
|
private resolvePossibleStringValues;
|
|
250
|
-
/**
|
|
251
|
-
* Finds and returns the full property node (KeyValueProperty) for the given
|
|
252
|
-
* property name from an ObjectExpression.
|
|
253
|
-
*
|
|
254
|
-
* Matches both identifier keys (e.g., { ns: 'value' }) and string literal keys
|
|
255
|
-
* (e.g., { 'ns': 'value' }).
|
|
256
|
-
*
|
|
257
|
-
* This helper returns the full property node rather than just its primitive
|
|
258
|
-
* value so callers can inspect expression types (ConditionalExpression, etc.).
|
|
259
|
-
*
|
|
260
|
-
* @private
|
|
261
|
-
* @param object - The SWC ObjectExpression to search
|
|
262
|
-
* @param propName - The property name to locate
|
|
263
|
-
* @returns The matching KeyValueProperty node if found, otherwise undefined.
|
|
264
|
-
*/
|
|
265
|
-
private getObjectProperty;
|
|
266
238
|
/**
|
|
267
239
|
* Finds the configuration for a given useTranslation function name.
|
|
268
240
|
* Applies default argument positions if none are specified.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-visitors.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/ast-visitors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA+G,MAAM,WAAW,CAAA;AACpJ,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ast-visitors.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/ast-visitors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA+G,MAAM,WAAW,CAAA;AACpJ,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAqB9E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,UAAU,CAAoC;IAE/C,UAAU,cAAoB;IAErC;;;;;;OAMG;gBAED,MAAM,EAAE,oBAAoB,EAC5B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM;IAOhB;;;;;OAKG;IACI,KAAK,CAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAMjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,IAAI;IAoDZ;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAIlB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAIjB;;;;;;;;OAQG;IACH,OAAO,CAAC,aAAa;IAMrB;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IASvB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,wBAAwB;IAmChC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,8BAA8B;IAwDtC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,yBAAyB;IAoBjC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAyI5B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,gBAAgB;IA4DxB;;;;;;;;OAQG;IACH,OAAO,CAAC,sBAAsB;IAkB9B;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IA2ExB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;IAgBtB;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,sBAAsB;IA2C9B;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,2BAA2B;IAmBnC;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAoB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CAAC,eAAe;CAwBxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-parser.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/jsx-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"jsx-parser.d.ts","sourceRoot":"","sources":["../../../src/extractor/parsers/jsx-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,yBAAyB,CAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CAoF9G"}
|
package/types/locize.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locize.d.ts","sourceRoot":"","sources":["../src/locize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"locize.d.ts","sourceRoot":"","sources":["../src/locize.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAgOnD,eAAO,MAAM,aAAa,GAAI,QAAQ,oBAAoB,EAAE,aAAa,GAAG,kBAAiD,CAAA;AAC7H,eAAO,MAAM,iBAAiB,GAAI,QAAQ,oBAAoB,EAAE,aAAa,GAAG,kBAAqD,CAAA;AACrI,eAAO,MAAM,gBAAgB,GAAI,QAAQ,oBAAoB,EAAE,aAAa,GAAG,kBAAoD,CAAA"}
|
package/types/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,SAAS,CAAA;AAGjE;;GAEG;AACH,UAAU,aAAa;IACrB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAgB,MAAM,SAAS,CAAA;AAGjE;;GAEG;AACH,UAAU,aAAa;IACrB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA4BD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,SAAS,CAAE,MAAM,EAAE,oBAAoB,EAAE,OAAO,GAAE,aAAkB,iBAYzF"}
|
package/types/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node, Expression } from '@swc/core';
|
|
1
|
+
import type { Node, Expression, ObjectExpression } from '@swc/core';
|
|
2
2
|
/**
|
|
3
3
|
* Main configuration interface for the i18next toolkit.
|
|
4
4
|
* Defines all available options for extraction, type generation, synchronization, and integrations.
|
|
@@ -210,6 +210,10 @@ export interface ExtractedKey {
|
|
|
210
210
|
ns?: string;
|
|
211
211
|
/** Whether this key is used with pluralization (count parameter) */
|
|
212
212
|
hasCount?: boolean;
|
|
213
|
+
/** Whether this key is used with ordinal pluralization */
|
|
214
|
+
isOrdinal?: boolean;
|
|
215
|
+
/** AST node for options object, used for advanced plural handling in Trans */
|
|
216
|
+
optionsNode?: ObjectExpression;
|
|
213
217
|
/** hold the raw context expression from the AST */
|
|
214
218
|
contextExpression?: Expression;
|
|
215
219
|
}
|
package/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,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,mGAAmG;QACnG,MAAM,EAAE,MAAM,CAAC;QAEf,wEAAwE;QACxE,SAAS,CAAC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AAI,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;CACzC"}
|
package/vitest.config.ts
CHANGED
|
@@ -8,6 +8,10 @@ export default defineConfig({
|
|
|
8
8
|
globals: true,
|
|
9
9
|
// Look for test files in the entire project
|
|
10
10
|
root: './',
|
|
11
|
+
coverage: {
|
|
12
|
+
include: ['src/**/*'],
|
|
13
|
+
exclude: ['src/types.ts', 'src/index.ts', 'src/extractor/index.ts']
|
|
14
|
+
}
|
|
11
15
|
},
|
|
12
16
|
plugins: [swc.vite()]
|
|
13
17
|
})
|