@@ -83,21 +83,19 @@ export default new Command()
8383 if ( flags . file ?. length ) {
8484 buckets = buckets
8585 . map ( ( bucket : any ) => {
86- const config = bucket . config . filter ( ( config : any ) =>
87- flags . file ! . find ( ( file ) => config . pathPattern ?. match ( file ) ) ,
88- ) ;
89- return { ...bucket , config } ;
86+ const paths = bucket . paths . filter ( ( path : any ) => flags . file ! . find ( ( file ) => path . pathPattern ?. match ( file ) ) ) ;
87+ return { ...bucket , paths } ;
9088 } )
91- . filter ( ( bucket : any ) => bucket . config . length > 0 ) ;
89+ . filter ( ( bucket : any ) => bucket . paths . length > 0 ) ;
9290 if ( buckets . length === 0 ) {
9391 ora . fail ( "No buckets found. All buckets were filtered out by --file option." ) ;
9492 process . exit ( 1 ) ;
9593 } else {
9694 ora . info ( `\x1b[36mProcessing only filtered buckets:\x1b[0m` ) ;
9795 buckets . map ( ( bucket : any ) => {
9896 ora . info ( ` ${ bucket . type } :` ) ;
99- bucket . config . forEach ( ( config : any ) => {
100- ora . info ( ` - ${ config . pathPattern } ` ) ;
97+ bucket . paths . forEach ( ( path : any ) => {
98+ ora . info ( ` - ${ path . pathPattern } ` ) ;
10199 } ) ;
102100 } ) ;
103101 }
@@ -111,18 +109,19 @@ export default new Command()
111109 if ( ! lockfileHelper . isLockfileExists ( ) ) {
112110 ora . start ( "Creating i18n.lock..." ) ;
113111 for ( const bucket of buckets ) {
114- for ( const bucketConfig of bucket . config ) {
115- const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketConfig . delimiter ) ;
112+ for ( const bucketPath of bucket . paths ) {
113+ const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketPath . delimiter ) ;
116114
117- const bucketLoader = createBucketLoader ( bucket . type , bucketConfig . pathPattern , {
115+ const bucketLoader = createBucketLoader ( bucket . type , bucketPath . pathPattern , {
118116 isCacheRestore : false ,
119117 defaultLocale : sourceLocale ,
118+ injectLocale : bucket . injectLocale ,
120119 } ) ;
121120 bucketLoader . setDefaultLocale ( sourceLocale ) ;
122121 await bucketLoader . init ( ) ;
123122
124123 const sourceData = await bucketLoader . pull ( i18nConfig ! . locale . source ) ;
125- lockfileHelper . registerSourceData ( bucketConfig . pathPattern , sourceData ) ;
124+ lockfileHelper . registerSourceData ( bucketPath . pathPattern , sourceData ) ;
126125 }
127126 }
128127 ora . succeed ( "i18n.lock created" ) ;
@@ -139,14 +138,15 @@ export default new Command()
139138
140139 for ( const bucket of buckets ) {
141140 cacheOra . info ( `Processing bucket: ${ bucket . type } ` ) ;
142- for ( const bucketConfig of bucket . config ) {
141+ for ( const bucketPath of bucket . paths ) {
143142 const bucketOra = Ora ( { indent : 4 } ) ;
144- bucketOra . info ( `Processing path: ${ bucketConfig . pathPattern } ` ) ;
143+ bucketOra . info ( `Processing path: ${ bucketPath . pathPattern } ` ) ;
145144
146- const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketConfig . delimiter ) ;
147- const bucketLoader = createBucketLoader ( bucket . type , bucketConfig . pathPattern , {
145+ const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketPath . delimiter ) ;
146+ const bucketLoader = createBucketLoader ( bucket . type , bucketPath . pathPattern , {
148147 isCacheRestore : true ,
149148 defaultLocale : sourceLocale ,
149+ injectLocale : bucket . injectLocale ,
150150 } ) ;
151151 bucketLoader . setDefaultLocale ( sourceLocale ) ;
152152 await bucketLoader . init ( ) ;
@@ -166,7 +166,7 @@ export default new Command()
166166 }
167167
168168 await bucketLoader . push ( targetLocale , targetData ) ;
169- lockfileHelper . registerPartialSourceData ( bucketConfig . pathPattern , cachedSourceData ) ;
169+ lockfileHelper . registerPartialSourceData ( bucketPath . pathPattern , cachedSourceData ) ;
170170
171171 bucketOra . succeed (
172172 `[${ sourceLocale } -> ${ targetLocale } ] Recovered ${ Object . keys ( cachedSourceData ) . length } entries from cache` ,
@@ -186,21 +186,22 @@ export default new Command()
186186 ora . start ( "Checking for lockfile updates..." ) ;
187187 let requiresUpdate : string | null = null ;
188188 bucketLoop: for ( const bucket of buckets ) {
189- for ( const bucketConfig of bucket . config ) {
190- const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketConfig . delimiter ) ;
189+ for ( const bucketPath of bucket . paths ) {
190+ const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketPath . delimiter ) ;
191191
192- const bucketLoader = createBucketLoader ( bucket . type , bucketConfig . pathPattern , {
192+ const bucketLoader = createBucketLoader ( bucket . type , bucketPath . pathPattern , {
193193 isCacheRestore : false ,
194194 defaultLocale : sourceLocale ,
195195 returnUnlocalizedKeys : true ,
196+ injectLocale : bucket . injectLocale ,
196197 } ) ;
197198 bucketLoader . setDefaultLocale ( sourceLocale ) ;
198199 await bucketLoader . init ( ) ;
199200
200201 const { unlocalizable : sourceUnlocalizable , ...sourceData } = await bucketLoader . pull (
201202 i18nConfig ! . locale . source ,
202203 ) ;
203- const updatedSourceData = lockfileHelper . extractUpdatedData ( bucketConfig . pathPattern , sourceData ) ;
204+ const updatedSourceData = lockfileHelper . extractUpdatedData ( bucketPath . pathPattern , sourceData ) ;
204205
205206 // translation was updated in the source file
206207 if ( Object . keys ( updatedSourceData ) . length > 0 ) {
@@ -209,7 +210,7 @@ export default new Command()
209210 }
210211
211212 for ( const _targetLocale of targetLocales ) {
212- const targetLocale = resolveOverriddenLocale ( _targetLocale , bucketConfig . delimiter ) ;
213+ const targetLocale = resolveOverriddenLocale ( _targetLocale , bucketPath . delimiter ) ;
213214 const { unlocalizable : targetUnlocalizable , ...targetData } = await bucketLoader . pull ( targetLocale ) ;
214215
215216 const missingKeys = _ . difference ( Object . keys ( sourceData ) , Object . keys ( targetData ) ) ;
@@ -257,29 +258,30 @@ export default new Command()
257258 try {
258259 console . log ( ) ;
259260 ora . info ( `Processing bucket: ${ bucket . type } ` ) ;
260- for ( const bucketConfig of bucket . config ) {
261- const bucketOra = Ora ( { indent : 2 } ) . info ( `Processing path: ${ bucketConfig . pathPattern } ` ) ;
261+ for ( const bucketPath of bucket . paths ) {
262+ const bucketOra = Ora ( { indent : 2 } ) . info ( `Processing path: ${ bucketPath . pathPattern } ` ) ;
262263
263- const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketConfig . delimiter ) ;
264+ const sourceLocale = resolveOverriddenLocale ( i18nConfig ! . locale . source , bucketPath . delimiter ) ;
264265
265- const bucketLoader = createBucketLoader ( bucket . type , bucketConfig . pathPattern , {
266+ const bucketLoader = createBucketLoader ( bucket . type , bucketPath . pathPattern , {
266267 isCacheRestore : false ,
267268 defaultLocale : sourceLocale ,
269+ injectLocale : bucket . injectLocale ,
268270 } ) ;
269271 bucketLoader . setDefaultLocale ( sourceLocale ) ;
270272 await bucketLoader . init ( ) ;
271273 let sourceData = await bucketLoader . pull ( sourceLocale ) ;
272274
273275 for ( const _targetLocale of targetLocales ) {
274- const targetLocale = resolveOverriddenLocale ( _targetLocale , bucketConfig . delimiter ) ;
276+ const targetLocale = resolveOverriddenLocale ( _targetLocale , bucketPath . delimiter ) ;
275277 try {
276278 bucketOra . start ( `[${ sourceLocale } -> ${ targetLocale } ] (0%) Localization in progress...` ) ;
277279
278280 sourceData = await bucketLoader . pull ( sourceLocale ) ;
279281
280282 const updatedSourceData = flags . force
281283 ? sourceData
282- : lockfileHelper . extractUpdatedData ( bucketConfig . pathPattern , sourceData ) ;
284+ : lockfileHelper . extractUpdatedData ( bucketPath . pathPattern , sourceData ) ;
283285
284286 const targetData = await bucketLoader . pull ( targetLocale ) ;
285287 let processableData = calculateDataDelta ( {
@@ -333,7 +335,7 @@ export default new Command()
333335 if ( flags . interactive ) {
334336 bucketOra . stop ( ) ;
335337 const reviewedData = await reviewChanges ( {
336- pathPattern : bucketConfig . pathPattern ,
338+ pathPattern : bucketPath . pathPattern ,
337339 targetLocale,
338340 currentData : targetData ,
339341 proposedData : finalTargetData ,
@@ -342,7 +344,7 @@ export default new Command()
342344 } ) ;
343345
344346 finalTargetData = reviewedData ;
345- bucketOra . start ( `Applying changes to ${ bucketConfig } (${ targetLocale } )` ) ;
347+ bucketOra . start ( `Applying changes to ${ bucketPath } (${ targetLocale } )` ) ;
346348 }
347349
348350 const finalDiffSize = _ . chain ( finalTargetData )
@@ -369,7 +371,7 @@ export default new Command()
369371 }
370372 }
371373
372- lockfileHelper . registerSourceData ( bucketConfig . pathPattern , sourceData ) ;
374+ lockfileHelper . registerSourceData ( bucketPath . pathPattern , sourceData ) ;
373375 }
374376 } catch ( _error : any ) {
375377 const error = new Error ( `Failed to process bucket ${ bucket . type } : ${ _error . message } ` ) ;
0 commit comments