mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 00:46:38 +01:00
#2065 Add option to translate text before classification
This commit is contained in:
parent
210f388d7a
commit
6290dff3d9
@ -977,6 +977,10 @@ async function getExpressionLabel(text) {
|
||||
return getFallbackExpression();
|
||||
}
|
||||
|
||||
if (extension_settings.expressions.translate && typeof window['translate'] === 'function') {
|
||||
text = await window['translate'](text, 'en');
|
||||
}
|
||||
|
||||
text = sampleClassifyText(text);
|
||||
|
||||
try {
|
||||
@ -1717,6 +1721,10 @@ async function fetchImagesNoCache() {
|
||||
$('#expressions_show_default').on('input', onExpressionsShowDefaultInput);
|
||||
$('#expression_upload_pack_button').on('click', onClickExpressionUploadPackButton);
|
||||
$('#expressions_show_default').prop('checked', extension_settings.expressions.showDefault).trigger('input');
|
||||
$('#expression_translate').prop('checked', extension_settings.expressions.translate).on('input', function () {
|
||||
extension_settings.expressions.translate = !!$(this).prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
$('#expression_local').prop('checked', extension_settings.expressions.local).on('input', function () {
|
||||
extension_settings.expressions.local = !!$(this).prop('checked');
|
||||
moduleWorker();
|
||||
|
@ -10,6 +10,10 @@
|
||||
<input id="expression_local" type="checkbox" />
|
||||
<span data-i18n="Local server classification">Local server classification</span>
|
||||
</label>
|
||||
<label class="checkbox_label" for="expression_translate" title="Use the selected API from Chat Translation extension settings.">
|
||||
<input id="expression_translate" type="checkbox">
|
||||
<span>Translate text to English before classification</span>
|
||||
</label>
|
||||
<label class="checkbox_label" for="expressions_show_default">
|
||||
<input id="expressions_show_default" type="checkbox">
|
||||
<span>Show default images (emojis) if sprite missing</span>
|
||||
|
@ -509,6 +509,8 @@ const handleOutgoingMessage = createEventHandler(translateOutgoingMessage, () =>
|
||||
const handleImpersonateReady = createEventHandler(translateImpersonate, () => shouldTranslate(incomingTypes));
|
||||
const handleMessageEdit = createEventHandler(translateMessageEdit, () => true);
|
||||
|
||||
window['translate'] = translate;
|
||||
|
||||
jQuery(() => {
|
||||
const html = `
|
||||
<div class="translation_settings">
|
||||
|
Loading…
Reference in New Issue
Block a user