Add ignored document lang option (#265)

This option allows you to list the locales for which you do not need to
apply translation.
This commit is contained in:
Alex Kozack 2021-03-08 16:08:07 +02:00 committed by GitHub
parent 6612e49710
commit 7c953f8244
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -137,6 +137,12 @@
"secondTargetLangCaptionLabel": {
"message": "Select the second target language."
},
"ignoredDocumentLangLabel": {
"message": "Ignore documents in the following languages"
},
"ignoredDocumentLangCaptionLabel": {
"message": "Comma separated languages that do not need to be translated."
},
"waitTimeLabel": {
"message": "Waiting time to translate"
},
@ -359,4 +365,4 @@
"openPopupDescription": {
"message": "Open toolbar popup"
}
}
}

View file

@ -28,8 +28,12 @@ const handleMouseUp = async e => {
if (!isLeftClick) return;
if (isInPasswordField) return;
if (isInThisElement) return;
removeTranslatecontainer();
const ignoredDocumentLang = getSettings('ignoredDocumentLang').split(',').map(s => s.trim()).filter(s => !!s)
if (!!document.documentElement.lang && ignoredDocumentLang.includes(document.documentElement.lang)) return;
const selectedText = getSelectedText();
prevSelectedText = selectedText;
if (selectedText.length === 0) return;

View file

@ -39,6 +39,15 @@ export default [
options: langListOptions,
useRawOptionName: true
},
{
id: "ignoredDocumentLang",
title: "ignoredDocumentLangLabel",
captions: ["ignoredDocumentLangCaptionLabel"],
type: "text",
default: "",
placeholder: "en, ru, ch",
new: true,
},
{
id: "ifShowCandidate",
title: "ifShowCandidateLabel",