Skip to content

Commit 4b1b962

Browse files
committed
fix ts issues: add localization for select box webview
1 parent 9854628 commit 4b1b962

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/messageTypes.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ export type LocalizedMessages = {
204204
// Common form strings
205205
integrationsRequiredField: string;
206206
integrationsOptionalField: string;
207+
// Select input settings strings
208+
selectInputSettingsTitle: string;
209+
allowMultipleValues: string;
210+
allowEmptyValue: string;
211+
valueSourceTitle: string;
212+
fromOptions: string;
213+
fromOptionsDescription: string;
214+
addOptionPlaceholder: string;
215+
addButton: string;
216+
fromVariable: string;
217+
fromVariableDescription: string;
218+
variablePlaceholder: string;
219+
saveButton: string;
220+
cancelButton: string;
207221
};
208222
// Map all messages to specific payloads
209223
export class IInteractiveWindowMapping {

src/notebooks/deepnote/selectInputSettingsWebview.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
} from 'vscode';
1616
import { inject, injectable } from 'inversify';
1717
import { IExtensionContext } from '../../platform/common/types';
18+
import { LocalizedMessages } from '../../messageTypes';
19+
import * as localize from '../../platform/common/utils/localize';
1820

1921
interface SelectInputSettings {
2022
allowMultipleValues: boolean;
@@ -91,6 +93,7 @@ export class SelectInputSettingsWebviewProvider {
9193

9294
// Send initial data
9395
await this.sendInitialData();
96+
await this.sendLocStrings();
9497

9598
// Return a promise that resolves when the user saves or cancels
9699
return new Promise((resolve) => {
@@ -119,6 +122,33 @@ export class SelectInputSettingsWebviewProvider {
119122
});
120123
}
121124

125+
private async sendLocStrings(): Promise<void> {
126+
if (!this.currentPanel) {
127+
return;
128+
}
129+
130+
const locStrings: Partial<LocalizedMessages> = {
131+
selectInputSettingsTitle: localize.SelectInputSettings.title,
132+
allowMultipleValues: localize.SelectInputSettings.allowMultipleValues,
133+
allowEmptyValue: localize.SelectInputSettings.allowEmptyValue,
134+
valueSourceTitle: localize.SelectInputSettings.valueSourceTitle,
135+
fromOptions: localize.SelectInputSettings.fromOptions,
136+
fromOptionsDescription: localize.SelectInputSettings.fromOptionsDescription,
137+
addOptionPlaceholder: localize.SelectInputSettings.addOptionPlaceholder,
138+
addButton: localize.SelectInputSettings.addButton,
139+
fromVariable: localize.SelectInputSettings.fromVariable,
140+
fromVariableDescription: localize.SelectInputSettings.fromVariableDescription,
141+
variablePlaceholder: localize.SelectInputSettings.variablePlaceholder,
142+
saveButton: localize.SelectInputSettings.saveButton,
143+
cancelButton: localize.SelectInputSettings.cancelButton
144+
};
145+
146+
await this.currentPanel.webview.postMessage({
147+
type: 'locInit',
148+
locStrings
149+
});
150+
}
151+
122152
private async handleMessage(message: { type: string; settings?: SelectInputSettings }): Promise<void> {
123153
switch (message.type) {
124154
case 'save':

src/platform/common/utils/localize.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,22 @@ export namespace Integrations {
859859
export const bigQueryUnnamedIntegration = (id: string) => l10n.t('Unnamed BigQuery Integration ({0})', id);
860860
}
861861

862+
export namespace SelectInputSettings {
863+
export const title = l10n.t('Settings');
864+
export const allowMultipleValues = l10n.t('Allow to select multiple values');
865+
export const allowEmptyValue = l10n.t('Allow empty value');
866+
export const valueSourceTitle = l10n.t('Value');
867+
export const fromOptions = l10n.t('From options');
868+
export const fromOptionsDescription = l10n.t('A set of defined options.');
869+
export const addOptionPlaceholder = l10n.t('Add option...');
870+
export const addButton = l10n.t('Add');
871+
export const fromVariable = l10n.t('From variable');
872+
export const fromVariableDescription = l10n.t('A list or Series that contains only strings, numbers or booleans.');
873+
export const variablePlaceholder = l10n.t('Variable name...');
874+
export const saveButton = l10n.t('Save');
875+
export const cancelButton = l10n.t('Cancel');
876+
}
877+
862878
export namespace Deprecated {
863879
export const SHOW_DEPRECATED_FEATURE_PROMPT_FORMAT_ON_SAVE = l10n.t({
864880
message: "The setting 'python.formatting.formatOnSave' is deprecated, please use 'editor.formatOnSave'.",

0 commit comments

Comments
 (0)