diff --git a/src/common/copilot/PowerPagesCopilot.ts b/src/common/copilot/PowerPagesCopilot.ts index 8d2bd8e9..05c3c569 100644 --- a/src/common/copilot/PowerPagesCopilot.ts +++ b/src/common/copilot/PowerPagesCopilot.ts @@ -22,6 +22,7 @@ import { INTELLIGENCE_SCOPE_DEFAULT, PROVIDER_ID } from "../../web/client/common import { getIntelligenceEndpoint } from "../ArtemisService"; import TelemetryReporter from "@vscode/extension-telemetry"; import { getEntityColumns, getEntityName } from "./dataverseMetadata"; +import { COPILOT_STRINGS } from "./assets/copilotStrings"; let intelligenceApiToken: string; let userID: string; // Populated from PAC or intelligence API @@ -177,6 +178,8 @@ export class PowerPagesCopilot implements vscode.WebviewViewProvider { webviewView.webview.onDidReceiveMessage(async (data) => { switch (data.type) { case "webViewLoaded": { + // Send the localized strings to the copilot webview + this.sendMessageToWebview({type: 'copilotStrings', value: COPILOT_STRINGS}) if (this.aibEndpoint === COPILOT_UNAVAILABLE) { this.sendMessageToWebview({ type: 'Unavailable' }); return; diff --git a/src/common/copilot/assets/copilotStrings.ts b/src/common/copilot/assets/copilotStrings.ts new file mode 100644 index 00000000..4a6e6037 --- /dev/null +++ b/src/common/copilot/assets/copilotStrings.ts @@ -0,0 +1,11 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + + +import vscode from "vscode"; + +export const COPILOT_STRINGS = { + EXPLAIN_CODE_PROMPT: vscode.l10n.t('Explain the following code:'), +} diff --git a/src/common/copilot/assets/scripts/copilot.js b/src/common/copilot/assets/scripts/copilot.js index a86cb669..c6d38907 100644 --- a/src/common/copilot/assets/scripts/copilot.js +++ b/src/common/copilot/assets/scripts/copilot.js @@ -21,6 +21,7 @@ let isLoggedIn = false; let apiResponseInProgress = false; let selectedCode = ""; + let copilotStrings = {}; const inputHistory = []; @@ -404,6 +405,10 @@ const message = event.data; // The JSON data our extension sent switch (message.type) { + case "copilotStrings": { + copilotStrings = message.value; //Localized string values object + break; + } case "apiResponse": { apiResponseHandler.updateResponse(message.value); apiResponseInProgress = false; @@ -472,7 +477,7 @@ } case "explainCode": { selectedCode = message.value.selectedCode; - const explainPrompt = 'Explain the following code:'; + const explainPrompt = copilotStrings.EXPLAIN_CODE_PROMPT; processUserInput(explainPrompt); }