@@ -3,7 +3,7 @@ import { ProjectAPI } from './api';
33import { ProjectDetails } from './apiTypes' ;
44import { getProjectApiKey , getProjectToken , onContentChanged , onProjectChanged } from './extension' ;
55import { repository } from './repository' ;
6- import { createMessageEntry , createQuickPickNamespacesItems , isProjectWithNamespaces } from './utils' ;
6+ import { createMessageEntry , createQuickPickLanguageItems , createQuickPickNamespacesItems , isProjectWithNamespaces } from './utils' ;
77
88export function registerSidebarTranslations ( context : vscode . ExtensionContext ) {
99 let recordsFiltered : SimpleLocalizeTranslationKeyItem [ ] = [ ] ;
@@ -165,11 +165,14 @@ export function registerSidebarTranslations(context: vscode.ExtensionContext) {
165165 }
166166
167167 let namespace = "" ;
168+ let maxSteps = 3 ;
169+ let currentStep = 1 ;
168170 const hasNamespaces = isProjectWithNamespaces ( ) ;
169171 if ( hasNamespaces ) {
172+ maxSteps = 4 ;
170173 const namespaceOptions = createQuickPickNamespacesItems ( ) ;
171174 const selectedNamespace = await vscode . window . showQuickPick ( namespaceOptions , {
172- title : " Add new translation key (1/2)" ,
175+ title : ` Add new translation key (${ currentStep ++ } / ${ maxSteps } )` ,
173176 placeHolder : "Choose namespace" ,
174177 } ) ;
175178 namespace = selectedNamespace ?. value || "" ;
@@ -178,10 +181,12 @@ export function registerSidebarTranslations(context: vscode.ExtensionContext) {
178181 const localTranslationKeys = repository . findAllTranslationKeys ( ) ;
179182 const localTranslationKeysByNamespace = localTranslationKeys . filter ( item => item . namespace === namespace ) ;
180183
184+
185+
181186 const translationKey = await vscode . window . showInputBox ( {
182187 value : inputText || "" ,
183188 placeHolder : "Enter translation key" ,
184- title : hasNamespaces ? " Add new translation key (2/2)" : "Add new translation key" ,
189+ title : ` Add new translation key (${ currentStep ++ } / ${ maxSteps } )` ,
185190 validateInput : ( value ) => {
186191 if ( ! value ) {
187192 return "Key is required" ;
@@ -198,10 +203,33 @@ export function registerSidebarTranslations(context: vscode.ExtensionContext) {
198203 }
199204 } ) ;
200205
201- if ( translationKey ) {
202- await projectApi . addTranslationKey ( translationKey , namespace ) ;
203- onContentChanged . fire ( ) ;
206+
207+ if ( ! translationKey ) {
208+ return ;
209+ }
210+
211+ await projectApi . addTranslationKey ( translationKey , namespace ) ;
212+ onContentChanged . fire ( ) ;
213+ vscode . window . showInformationMessage ( `Translation key "${ translationKey } " added.` ) ;
214+
215+ const languageQuickPickOptions = createQuickPickLanguageItems ( ) ;
216+ const selectedLanguage = await vscode . window . showQuickPick ( languageQuickPickOptions , {
217+ title : `Choose language for translation (${ currentStep ++ } /${ maxSteps } )` ,
218+ placeHolder : "Choose language"
219+ } ) ;
220+
221+ if ( ! selectedLanguage ) {
222+ return ;
204223 }
224+
225+ const translation = await vscode . window . showInputBox ( {
226+ value : "" ,
227+ placeHolder : "Enter translation" ,
228+ title : `Add translation (${ currentStep } /${ maxSteps } )` ,
229+ } ) ;
230+
231+ await projectApi . updateTranslation ( translationKey , namespace , selectedLanguage . key , translation ) ;
232+ onContentChanged . fire ( ) ;
205233 } ) ;
206234
207235 vscode . commands . registerCommand ( 'simplelocalize.copyTranslationKey' , async ( active : SimpleLocalizeTranslationKeyItem ) => {
0 commit comments