@@ -13,6 +13,7 @@ export interface FilterSpec {
1313export interface ListOptions {
1414 path : string ;
1515 languages ?: string [ ] ;
16+ missingLanguages ?: string [ ] ;
1617 keyFilter ?: FilterSpec ;
1718 textFilter ?: FilterSpec ;
1819 format ?: string ;
@@ -61,6 +62,11 @@ export function createStringsCommand(): CommandModule {
6162 alias : 'l' ,
6263 describe : 'Include only these languages' ,
6364 } )
65+ . option ( 'missing-languages' , {
66+ type : 'string' ,
67+ array : true ,
68+ describe : 'Include only keys missing any of these languages' ,
69+ } )
6470 . option ( 'format' , {
6571 type : 'string' ,
6672 describe : 'Mustache template. Available variables: {{language}}, {{key}}, {{text}}' ,
@@ -101,6 +107,7 @@ export function createStringsCommand(): CommandModule {
101107 const output = await strings ( {
102108 path : argv . path as string ,
103109 languages : argv . languages as string [ ] | undefined ,
110+ missingLanguages : argv [ 'missing-languages' ] as string [ ] | undefined ,
104111 keyFilter,
105112 textFilter,
106113 format : argv . format as string | undefined ,
@@ -150,6 +157,7 @@ export async function strings(options: ListOptions): Promise<string> {
150157 const matchKey = buildMatcher ( options . keyFilter ) ;
151158 const matchText = buildMatcher ( options . textFilter ) ;
152159 const languageSet = options . languages ? new Set ( options . languages ) : null ;
160+ const missingLanguageSet = options . missingLanguages ? new Set ( options . missingLanguages ) : null ;
153161 const useTemplate = Boolean ( options . format ) ;
154162
155163 const lines : string [ ] = [ ] ;
@@ -161,6 +169,10 @@ export async function strings(options: ListOptions): Promise<string> {
161169 const localizations = unit ?. localizations ?? { } ;
162170 const localizationKeys = Object . keys ( localizations ) ;
163171
172+ const isMissingSpecifiedLanguage = missingLanguageSet
173+ ? Array . from ( missingLanguageSet ) . some ( ( lang ) => ! ( lang in localizations ) )
174+ : true ;
175+
164176 const perKeyLines : string [ ] = [ ] ;
165177
166178 for ( const lang of localizationKeys ) {
@@ -179,6 +191,10 @@ export async function strings(options: ListOptions): Promise<string> {
179191 continue ;
180192 }
181193
194+ if ( ! isMissingSpecifiedLanguage ) {
195+ continue ;
196+ }
197+
182198 if ( useTemplate ) {
183199 lines . push ( ...perKeyLines ) ;
184200 } else {
0 commit comments