mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Work on tl
This commit is contained in:
@@ -40,6 +40,7 @@ import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
|
||||
import { ScraperManager } from './scrapers.js';
|
||||
import { DragAndDropHandler } from './dragdrop.js';
|
||||
import { renderTemplateAsync } from './templates.js';
|
||||
import { t } from './i18n.js';
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileAttachment
|
||||
@@ -206,7 +207,7 @@ export async function populateFileAttachment(message, inputId = 'file_form_input
|
||||
const fileText = await converter(file);
|
||||
base64Data = window.btoa(unescape(encodeURIComponent(fileText)));
|
||||
} catch (error) {
|
||||
toastr.error(String(error), 'Could not convert file');
|
||||
toastr.error(String(error), t`Could not convert file`);
|
||||
console.error('Could not convert file', error);
|
||||
}
|
||||
}
|
||||
@@ -257,7 +258,7 @@ export async function uploadFileAttachment(fileName, base64Data) {
|
||||
const responseData = await result.json();
|
||||
return responseData.path;
|
||||
} catch (error) {
|
||||
toastr.error(String(error), 'Could not upload file');
|
||||
toastr.error(String(error), t`Could not upload file`);
|
||||
console.error('Could not upload file', error);
|
||||
}
|
||||
}
|
||||
@@ -283,7 +284,7 @@ export async function getFileAttachment(url) {
|
||||
const text = await result.text();
|
||||
return text;
|
||||
} catch (error) {
|
||||
toastr.error(error, 'Could not download file');
|
||||
toastr.error(error, t`Could not download file`);
|
||||
console.error('Could not download file', error);
|
||||
}
|
||||
}
|
||||
@@ -299,13 +300,13 @@ async function validateFile(file) {
|
||||
const isBinary = /^[\x00-\x08\x0E-\x1F\x7F-\xFF]*$/.test(fileText);
|
||||
|
||||
if (!isImage && file.size > fileSizeLimit) {
|
||||
toastr.error(`File is too big. Maximum size is ${humanFileSize(fileSizeLimit)}.`);
|
||||
toastr.error(t`File is too big. Maximum size is ${humanFileSize(fileSizeLimit)}.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If file is binary
|
||||
if (isBinary && !isImage && !isConvertible(file.type)) {
|
||||
toastr.error('Binary files are not supported. Select a text file or image.');
|
||||
toastr.error(t`Binary files are not supported. Select a text file or image.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -521,7 +522,7 @@ async function openExternalMediaOverridesDialog() {
|
||||
const entityId = getCurrentEntityId();
|
||||
|
||||
if (!entityId) {
|
||||
toastr.info('No character or group selected');
|
||||
toastr.info(t`No character or group selected`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -646,7 +647,7 @@ async function deleteFileFromServer(url, silent = false) {
|
||||
await eventSource.emit(event_types.FILE_ATTACHMENT_DELETED, url);
|
||||
return true;
|
||||
} catch (error) {
|
||||
toastr.error(String(error), 'Could not delete file');
|
||||
toastr.error(String(error), t`Could not delete file`);
|
||||
console.error('Could not delete file', error);
|
||||
return false;
|
||||
}
|
||||
@@ -1054,7 +1055,7 @@ async function openAttachmentManager() {
|
||||
const selectedAttachments = document.querySelectorAll('.attachmentListItemCheckboxContainer .attachmentListItemCheckbox:checked');
|
||||
|
||||
if (selectedAttachments.length === 0) {
|
||||
toastr.info('No attachments selected.', 'Data Bank');
|
||||
toastr.info(t`No attachments selected.`, t`Data Bank`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1168,7 +1169,7 @@ async function runScraper(scraperId, target, callback) {
|
||||
|
||||
if (files.length === 0) {
|
||||
console.warn('Scraping returned no files');
|
||||
toastr.info('No files were scraped.', 'Data Bank');
|
||||
toastr.info(t`No files were scraped.`, t`Data Bank`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1176,12 +1177,12 @@ async function runScraper(scraperId, target, callback) {
|
||||
await uploadFileAttachmentToServer(file, target);
|
||||
}
|
||||
|
||||
toastr.success(`Scraped ${files.length} files from ${scraperId} to ${target}.`, 'Data Bank');
|
||||
toastr.success(t`Scraped ${files.length} files from ${scraperId} to ${target}.`, t`Data Bank`);
|
||||
callback();
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Scraping failed', error);
|
||||
toastr.error('Check browser console for details.', 'Scraping failed');
|
||||
toastr.error(t`Check browser console for details.`, t`Scraping failed`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1208,7 +1209,7 @@ export async function uploadFileAttachmentToServer(file, target) {
|
||||
const fileText = await converter(file);
|
||||
base64Data = window.btoa(unescape(encodeURIComponent(fileText)));
|
||||
} catch (error) {
|
||||
toastr.error(String(error), 'Could not convert file');
|
||||
toastr.error(String(error), t`Could not convert file`);
|
||||
console.error('Could not convert file', error);
|
||||
}
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user