Work on tl

This commit is contained in:
Yokayo
2024-10-01 21:25:20 +07:00
parent 5489dd61a7
commit 7f9023d3c2
13 changed files with 286 additions and 145 deletions

View File

@ -8,6 +8,7 @@ import { debounce, waitUntilCondition, escapeHtml } from './utils.js';
import { debounce_timeout } from './constants.js';
import { renderTemplateAsync } from './templates.js';
import { Popup } from './popup.js';
import { t } from './i18n.js';
function debouncePromise(func, delay) {
let timeoutId;
@ -455,7 +456,7 @@ class PromptManager {
// Delete selected prompt from list form and close edit form
this.handleDeletePrompt = async (event) => {
Popup.show.confirm('Are you sure you want to delete this prompt?', null).then((userChoice) => {
Popup.show.confirm(t`Are you sure you want to delete this prompt?`, null).then((userChoice) => {
if (!userChoice) return;
const promptID = document.getElementById(this.configuration.prefix + 'prompt_manager_footer_append_prompt').value;
const prompt = this.getPromptById(promptID);
@ -531,7 +532,7 @@ class PromptManager {
// Import prompts for the selected character
this.handleImport = () => {
Popup.show.confirm('Existing prompts with the same ID will be overridden. Do you want to proceed?', null)
Popup.show.confirm(t`Existing prompts with the same ID will be overridden. Do you want to proceed?`, null)
.then(userChoice => {
if (!userChoice) return;
@ -552,7 +553,7 @@ class PromptManager {
const data = JSON.parse(fileContent);
this.import(data);
} catch (err) {
toastr.error('An error occurred while importing prompts. More info available in console.');
toastr.error(t`An error occurred while importing prompts. More info available in console.`);
console.log('An error occurred while importing prompts');
console.log(err.toString());
}
@ -567,7 +568,7 @@ class PromptManager {
// Restore default state of a characters prompt order
this.handleCharacterReset = () => {
Popup.show.confirm('This will reset the prompt order for this character. You will not lose any prompts.', null)
Popup.show.confirm(t`This will reset the prompt order for this character. You will not lose any prompts.`, null)
.then(userChoice => {
if (!userChoice) return;
@ -1649,7 +1650,7 @@ class PromptManager {
};
if (false === this.validateObject(controlObj, importData)) {
toastr.warning('Could not import prompts. Export failed validation.');
toastr.warning(t`Could not import prompts. Export failed validation.`);
return;
}
@ -1672,7 +1673,7 @@ class PromptManager {
throw new Error('Prompt order strategy not supported.');
}
toastr.success('Prompt import complete.');
toastr.success(t`Prompt import complete.`);
this.saveServiceSettings().then(() => this.render());
}