Skip to content

Commit e8f0be2

Browse files
committed
Switch to 1.94.x of VSC Engine
1 parent ce5c60e commit e8f0be2

File tree

3 files changed

+51
-14
lines changed

3 files changed

+51
-14
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
"formatjs",
3131
"arb"
3232
],
33-
"version": "1.0.9",
33+
"version": "1.0.12",
3434
"engines": {
35-
"vscode": "^1.95.0"
35+
"vscode": "^1.94.0"
3636
},
3737
"categories": [
3838
"Programming Languages",
@@ -322,7 +322,7 @@
322322
"devDependencies": {
323323
"@types/mocha": "^10.0.9",
324324
"@types/node": "20.x",
325-
"@types/vscode": "^1.95.0",
325+
"@types/vscode": "^1.94.0",
326326
"@typescript-eslint/eslint-plugin": "^8.10.0",
327327
"@typescript-eslint/parser": "^8.7.0",
328328
"@vscode/test-cli": "^0.0.10",

src/codeAction.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,22 @@ async function renameTranslationKeyAction(selectedText: string) {
183183
return;
184184
}
185185

186-
const newNamespace = await vscode.window.showQuickPick(createQuickPickNamespacesItems(), {
187-
title: hasNamespaces ? `Step 3/${maxSteps}: Choose new namespace` : undefined,
188-
placeHolder: "Choose namespace"
189-
});
186+
187+
let newNamespace: string = "";
188+
if (hasNamespaces) {
189+
const userNamespace = await vscode.window.showQuickPick(createQuickPickNamespacesItems(), {
190+
title: hasNamespaces ? `Step 3/${maxSteps}: Choose new namespace` : undefined,
191+
placeHolder: "Choose namespace"
192+
});
193+
if (userNamespace) {
194+
newNamespace = userNamespace?.value || "";
195+
} else {
196+
return;
197+
}
198+
}
190199

191200
const projectApi = new ProjectAPI(apiKey);
192-
await projectApi.updateTranslationKey(selectedText, namespace, newTranslationKey, newNamespace?.value);
201+
await projectApi.updateTranslationKey(selectedText, namespace, newTranslationKey, newNamespace);
193202
onContentChanged.fire();
194203

195204
editor.edit(editBuilder => {

src/sidebarTranslations.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ProjectAPI } from './api';
33
import { ProjectDetails } from './apiTypes';
44
import { getProjectApiKey, getProjectToken, onContentChanged, onProjectChanged } from './extension';
55
import { repository } from './repository';
6-
import { createMessageEntry, createQuickPickNamespacesItems, isProjectWithNamespaces } from './utils';
6+
import { createMessageEntry, createQuickPickLanguageItems, createQuickPickNamespacesItems, isProjectWithNamespaces } from './utils';
77

88
export 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

Comments
 (0)