@@ -6,7 +6,7 @@ import Ora from 'ora';
6
6
import _ from 'lodash' ;
7
7
import { createBucketProcessor } from './workers/bucket' ;
8
8
import { createEngine } from './workers/engine' ;
9
- import { allLocalesSchema } from '@replexica/spec' ;
9
+ import { targetLocaleSchema } from '@replexica/spec' ;
10
10
import { createLockfileProcessor } from './workers/lockfile' ;
11
11
import { createAuthenticator } from './workers/auth' ;
12
12
@@ -15,6 +15,7 @@ export default new Command()
15
15
. description ( 'Run AI localization engine' )
16
16
. helpOption ( '-h, --help' , 'Show help' )
17
17
. option ( '--locale <locale>' , 'Locale to process' )
18
+ . option ( '--bucket <bucket>' , 'Bucket to process' )
18
19
. option ( '--force' , 'Ignore lockfile and process all keys' )
19
20
. action ( async function ( options ) {
20
21
const ora = Ora ( ) ;
@@ -34,6 +35,10 @@ export default new Command()
34
35
throw new Error ( 'i18n.json not found. Please run `replexica init` to initialize the project.' ) ;
35
36
} else if ( ! i18nConfig . buckets || ! Object . keys ( i18nConfig . buckets ) . length ) {
36
37
throw new Error ( 'No buckets found in i18n.json. Please add at least one bucket containing i18n content.' ) ;
38
+ } else if ( flags . locale && ! i18nConfig . locale . targets . includes ( flags . locale ) ) {
39
+ throw new Error ( `Source locale ${ i18nConfig . locale . source } does not exist in i18n.json locale.targets. Please add it to the list and try again.` ) ;
40
+ } else if ( flags . bucket && ! i18nConfig . buckets [ flags . bucket ] ) {
41
+ throw new Error ( `Bucket ${ flags . bucket } does not exist in i18n.json. Please add it to the list and try again.` ) ;
37
42
} else {
38
43
ora . succeed ( 'Replexica configuration loaded' ) ;
39
44
}
@@ -57,7 +62,8 @@ export default new Command()
57
62
ora . succeed ( 'AI localization engine connected' ) ;
58
63
59
64
const lockfileProcessor = createLockfileProcessor ( ) ;
60
- for ( const [ bucketPath , bucketType ] of Object . entries ( i18nConfig . buckets ) ) {
65
+ const targetedBuckets = flags . bucket ? { [ flags . bucket ] : i18nConfig . buckets [ flags . bucket ] } : i18nConfig . buckets ;
66
+ for ( const [ bucketPath , bucketType ] of Object . entries ( targetedBuckets ) ) {
61
67
console . log ( '' ) ;
62
68
const bucketOra = Ora ( { } ) ;
63
69
// Create the payload processor instance for the current bucket type
@@ -138,7 +144,8 @@ export default new Command()
138
144
139
145
async function loadFlags ( options : any ) {
140
146
return Z . object ( {
141
- locale : allLocalesSchema . optional ( ) ,
147
+ locale : targetLocaleSchema . optional ( ) ,
148
+ bucket : Z . string ( ) . optional ( ) ,
142
149
force : Z . boolean ( ) . optional ( ) ,
143
150
} ) . parse ( options ) ;
144
151
}
0 commit comments