#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();
|
return getFallbackExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extension_settings.expressions.translate && typeof window['translate'] === 'function') {
|
||||||
|
text = await window['translate'](text, 'en');
|
||||||
|
}
|
||||||
|
|
||||||
text = sampleClassifyText(text);
|
text = sampleClassifyText(text);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -1717,6 +1721,10 @@ async function fetchImagesNoCache() {
|
||||||
$('#expressions_show_default').on('input', onExpressionsShowDefaultInput);
|
$('#expressions_show_default').on('input', onExpressionsShowDefaultInput);
|
||||||
$('#expression_upload_pack_button').on('click', onClickExpressionUploadPackButton);
|
$('#expression_upload_pack_button').on('click', onClickExpressionUploadPackButton);
|
||||||
$('#expressions_show_default').prop('checked', extension_settings.expressions.showDefault).trigger('input');
|
$('#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 () {
|
$('#expression_local').prop('checked', extension_settings.expressions.local).on('input', function () {
|
||||||
extension_settings.expressions.local = !!$(this).prop('checked');
|
extension_settings.expressions.local = !!$(this).prop('checked');
|
||||||
moduleWorker();
|
moduleWorker();
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
<input id="expression_local" type="checkbox" />
|
<input id="expression_local" type="checkbox" />
|
||||||
<span data-i18n="Local server classification">Local server classification</span>
|
<span data-i18n="Local server classification">Local server classification</span>
|
||||||
</label>
|
</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">
|
<label class="checkbox_label" for="expressions_show_default">
|
||||||
<input id="expressions_show_default" type="checkbox">
|
<input id="expressions_show_default" type="checkbox">
|
||||||
<span>Show default images (emojis) if sprite missing</span>
|
<span>Show default images (emojis) if sprite missing</span>
|
||||||
|
|
|
@ -509,6 +509,8 @@ const handleOutgoingMessage = createEventHandler(translateOutgoingMessage, () =>
|
||||||
const handleImpersonateReady = createEventHandler(translateImpersonate, () => shouldTranslate(incomingTypes));
|
const handleImpersonateReady = createEventHandler(translateImpersonate, () => shouldTranslate(incomingTypes));
|
||||||
const handleMessageEdit = createEventHandler(translateMessageEdit, () => true);
|
const handleMessageEdit = createEventHandler(translateMessageEdit, () => true);
|
||||||
|
|
||||||
|
window['translate'] = translate;
|
||||||
|
|
||||||
jQuery(() => {
|
jQuery(() => {
|
||||||
const html = `
|
const html = `
|
||||||
<div class="translation_settings">
|
<div class="translation_settings">
|
||||||
|
|
Loading…
Reference in New Issue