diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 452cff8e..fd8bff0e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1222,5 +1222,33 @@ "chatgpt_win_diff_title": { "message": "Differences between the original and the modified text", "description": "" + }, + "apiwebchat_you": { + "message": "You", + "description": "" + }, + "apiwebchat_info": { + "message": "Information", + "description": "" + }, + "apiwebchat_error": { + "message": "Error", + "description": "" + }, + "apiwebchat_use_this_answer": { + "message": "Use this answer", + "description": "" + }, + "apiwebchat_show_differences": { + "message": "Show differences", + "description": "" + }, + "apiwebchat_stopping": { + "message": "Stopping", + "description": "" + }, + "apiwebchat_receiving_data": { + "message": "Receiving data", + "description": "" } } \ No newline at end of file diff --git a/api_webchat/controller.js b/api_webchat/controller.js index 5f5f23ce..ec23e569 100644 --- a/api_webchat/controller.js +++ b/api_webchat/controller.js @@ -126,7 +126,7 @@ worker.onmessage = function(event) { break; case 'newToken': messagesArea.handleNewToken(payload.token); - messageInput.setStatusMessage('Receiving data...'); + messageInput.setStatusMessage(browser.i18n.getMessage("apiwebchat_receiving_data") + '...'); break; case 'tokensDone': messagesArea.handleTokensDone(promptData); diff --git a/api_webchat/messageInput.js b/api_webchat/messageInput.js index 01bc1d3c..15925640 100644 --- a/api_webchat/messageInput.js +++ b/api_webchat/messageInput.js @@ -216,7 +216,7 @@ class MessageInput extends HTMLElement { _handleStopClick() { this.worker.postMessage({ type: 'stop' }); this._stopButton.setAttribute('disabled', 'disabled'); - this._stopButton.title = 'Stopping...'; + this._stopButton.title = browser.i18n.getMessage("apiwebchat_stopping") + '...'; } _handleNewChatMessage() { diff --git a/api_webchat/messagesArea.js b/api_webchat/messagesArea.js index 4f3ea96d..955a0c51 100644 --- a/api_webchat/messagesArea.js +++ b/api_webchat/messagesArea.js @@ -162,13 +162,13 @@ class MessagesArea extends HTMLElement { this.fullTextHTML = ""; // console.log("[ThunderAI] appendUserMessage: " + messageText); const header = document.createElement('h2'); - let source = "You"; + let source = browser.i18n.getMessage("apiwebchat_you"); switch (type) { case "user": - source = "You"; + source = browser.i18n.getMessage("apiwebchat_you");; break; case "info": - source = "Information"; + source = browser.i18n.getMessage("apiwebchat_info"); break; } header.textContent = source; @@ -191,7 +191,7 @@ class MessagesArea extends HTMLElement { if (isLastMessageFromUser) { const header = document.createElement('h2'); - header.textContent = this.llmName + (type=='error' ? " - Error" : ""); + header.textContent = this.llmName + (type=='error' ? " - " + browser.i18n.getMessage("apiwebchat_error") : ""); this.messages.appendChild(header); } @@ -228,8 +228,7 @@ class MessagesArea extends HTMLElement { const actionButtons = document.createElement('div'); actionButtons.classList.add('action-buttons'); const actionButton = document.createElement('button'); - actionButton.textContent = 'Use this answer'; - //actionButton.textContent = browser.i18n.getMessage("chatgpt_win_get_answer"); + actionButton.textContent = browser.i18n.getMessage("apiwebchat_use_this_answer"); const fullTextHTMLAtAssignment = this.fullTextHTML.trim().replace(/^"|"$/g, '').replace(/^
"/, '
').replace(/"<\/p>$/, '
'); // strip quotation marks //console.log(">>>>>>>>>>>> fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment); actionButton.addEventListener('click', async () => { @@ -257,7 +256,7 @@ class MessagesArea extends HTMLElement { // diff viewer button if(promptData.prompt_info?.use_diff_viewer == "1") { const diffvButton = document.createElement('button'); - diffvButton.textContent = 'Show differences'; + diffvButton.textContent = browser.i18n.getMessage("apiwebchat_show_differences"); diffvButton.addEventListener('click', async () => { let strippedText = fullTextHTMLAtAssignment.replace(/<\/?[^>]+(>|$)/g, ""); let originalText = promptData.prompt_info?.selection_text; @@ -307,7 +306,7 @@ class MessagesArea extends HTMLElement { }); const header = document.createElement('h2'); - header.textContent = "Diff viewer"; + header.textContent = browser.i18n.getMessage("chatgpt_win_diff_title"); this.messages.appendChild(header); this.messages.appendChild(messageElement);