diff --git a/src/config/i18n.js b/src/config/i18n.js
index d5086bc..d4ab356 100644
--- a/src/config/i18n.js
+++ b/src/config/i18n.js
@@ -1033,6 +1033,11 @@ export const I18N = {
en: `After enabling, the detection accuracy will increase, but it will reduce the translation speed. Please enable it as appropriate.`,
zh_TW: `啟用後可提升偵測準確度,但會降低翻譯速度,請視需要開啟。`,
},
+ detect_lang_service: {
+ zh: `语言检测服务`,
+ en: `Language detect service`,
+ zh_TW: `語言檢測服務`,
+ },
disable: {
zh: `禁用`,
en: `Disable`,
diff --git a/src/config/rules.js b/src/config/rules.js
index 5929395..6ba2964 100644
--- a/src/config/rules.js
+++ b/src/config/rules.js
@@ -96,8 +96,8 @@ export const DEFAULT_RULE = {
transTag: GLOBAL_KEY, // 译文元素标签
transTitle: GLOBAL_KEY, // 是否同时翻译页面标题
transSelected: GLOBAL_KEY, // 是否启用划词翻译
- detectRemote: GLOBAL_KEY, // 是否使用远程语言检测
- skipLangs: [], // 不翻译的语言
+ // detectRemote: GLOBAL_KEY, // 是否使用远程语言检测 (移回setting)
+ // skipLangs: [], // 不翻译的语言 (移回setting)
// fixerSelector: "", // 修复函数选择器 (暂时作废)
// fixerFunc: GLOBAL_KEY, // 修复函数 (暂时作废)
transStartHook: "", // 钩子函数
@@ -132,8 +132,8 @@ export const GLOBLA_RULE = {
transTag: DEFAULT_TRANS_TAG, // 译文元素标签
transTitle: "false", // 是否同时翻译页面标题
transSelected: "true", // 是否启用划词翻译
- detectRemote: "true", // 是否使用远程语言检测
- skipLangs: [], // 不翻译的语言
+ // detectRemote: "true", // 是否使用远程语言检测 (移回setting)
+ // skipLangs: [], // 不翻译的语言 (移回setting)
// fixerSelector: "", // 修复函数选择器 (暂时作废)
// fixerFunc: "-", // 修复函数 (暂时作废)
transStartHook: "", // 钩子函数
diff --git a/src/config/setting.js b/src/config/setting.js
index 1f4bafb..3585b12 100644
--- a/src/config/setting.js
+++ b/src/config/setting.js
@@ -4,7 +4,6 @@ import {
OPT_TRANS_MICROSOFT,
DEFAULT_API_LIST,
} from "./api";
-import { DEFAULT_OW_RULE } from "./rules";
// 默认快捷键
export const OPT_SHORTCUT_TRANSLATE = "toggleTranslate";
@@ -128,7 +127,7 @@ export const DEFAULT_SETTING = {
injectRules: true, // 是否注入订阅规则
fabClickAction: 0, // 悬浮按钮点击行为
// injectWebfix: true, // 是否注入修复补丁(作废)
- // detectRemote: false, // 是否使用远程语言检测(移至rule,作废)
+ detectRemote: false, // 是否使用远程语言检测 (从rule移回)
// contextMenus: true, // 是否添加右键菜单(作废)
contextMenuType: 1, // 右键菜单类型(0不显示,1简单菜单,2多级菜单)
// transTag: DEFAULT_TRANS_TAG, // 译文元素标签(移至rule,作废)
@@ -145,6 +144,7 @@ export const DEFAULT_SETTING = {
blacklist: DEFAULT_BLACKLIST.join(",\n"), // 禁用翻译名单
csplist: DEFAULT_CSPLIST.join(",\n"), // 禁用CSP名单
// disableLangs: [], // 不翻译的语言(移至rule,作废)
+ skipLangs: [], // 不翻译的语言(从rule移回)
transInterval: 100, // 翻译等待时间
langDetector: OPT_TRANS_MICROSOFT, // 远程语言识别服务
mouseHoverSetting: DEFAULT_MOUSE_HOVER_SETTING, // 鼠标悬停翻译
diff --git a/src/libs/detect.js b/src/libs/detect.js
index d6af90e..32f52e1 100644
--- a/src/libs/detect.js
+++ b/src/libs/detect.js
@@ -29,13 +29,13 @@ const langdetectFns = {
*/
export const tryDetectLang = async (
text,
- useRemote = "false",
+ detectRemote = true,
langDetector = OPT_TRANS_MICROSOFT
) => {
let deLang = "";
// 远程识别
- if (useRemote === "true" && langDetector) {
+ if (detectRemote && langDetector) {
try {
const lang = await langdetectFns[langDetector](text);
if (lang) {
diff --git a/src/libs/rules.js b/src/libs/rules.js
index e3cc7d6..5c52cd3 100644
--- a/src/libs/rules.js
+++ b/src/libs/rules.js
@@ -1,7 +1,6 @@
import { matchValue, type, isMatch } from "./utils";
import {
GLOBAL_KEY,
- REMAIN_KEY,
OPT_STYLE_ALL,
OPT_LANGS_FROM,
OPT_LANGS_TO,
@@ -80,7 +79,7 @@ export const matchRule = async (href, { injectRules, subrulesList }) => {
"transTag",
"transTitle",
"transSelected",
- "detectRemote",
+ // "detectRemote",
// "fixerFunc",
].forEach((key) => {
if (rule[key] === undefined || rule[key] === GLOBAL_KEY) {
@@ -88,9 +87,9 @@ export const matchRule = async (href, { injectRules, subrulesList }) => {
}
});
- if (!rule.skipLangs || rule.skipLangs.length === 0) {
- rule.skipLangs = globalRule.skipLangs;
- }
+ // if (!rule.skipLangs || rule.skipLangs.length === 0) {
+ // rule.skipLangs = globalRule.skipLangs;
+ // }
if (rule.textStyle === GLOBAL_KEY) {
rule.textStyle = globalRule.textStyle;
rule.bgColor = globalRule.bgColor;
@@ -155,8 +154,8 @@ export const checkRules = (rules) => {
transTag,
transTitle,
transSelected,
- detectRemote,
- skipLangs,
+ // detectRemote,
+ // skipLangs,
// fixerSelector,
// fixerFunc,
transStartHook,
@@ -188,8 +187,8 @@ export const checkRules = (rules) => {
transTag: matchValue([GLOBAL_KEY, "span", "font"], transTag),
transTitle: matchValue([GLOBAL_KEY, "true", "false"], transTitle),
transSelected: matchValue([GLOBAL_KEY, "true", "false"], transSelected),
- detectRemote: matchValue([GLOBAL_KEY, "true", "false"], detectRemote),
- skipLangs: type(skipLangs) === "array" ? skipLangs : [],
+ // detectRemote: matchValue([GLOBAL_KEY, "true", "false"], detectRemote),
+ // skipLangs: type(skipLangs) === "array" ? skipLangs : [],
// fixerSelector: type(fixerSelector) === "string" ? fixerSelector : "",
transStartHook: type(transStartHook) === "string" ? transStartHook : "",
transEndHook: type(transEndHook) === "string" ? transEndHook : "",
diff --git a/src/libs/translator.js b/src/libs/translator.js
index 34290e2..2340cc4 100644
--- a/src/libs/translator.js
+++ b/src/libs/translator.js
@@ -740,12 +740,8 @@ export class Translator {
// 提前进行语言检测
let deLang = "";
- const {
- detectRemote,
- fromLang = "auto",
- toLang,
- skipLangs = [],
- } = this.#rule;
+ const { fromLang = "auto", toLang } = this.#rule;
+ const { detectRemote, skipLangs = [] } = this.#setting;
if (fromLang === "auto") {
const { langDetector } = this.#setting;
deLang = await tryDetectLang(
diff --git a/src/views/Options/Rules.js b/src/views/Options/Rules.js
index ffbadee..6e5a40c 100644
--- a/src/views/Options/Rules.js
+++ b/src/views/Options/Rules.js
@@ -113,8 +113,8 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
transTag = DEFAULT_TRANS_TAG,
transTitle = "false",
transSelected = "true",
- detectRemote = "true",
- skipLangs = [],
+ // detectRemote = "true",
+ // skipLangs = [],
// fixerSelector = "",
// fixerFunc = "-",
transStartHook = "",
@@ -478,23 +478,6 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
))}
*/}
-
-
-
- {GlobalItem}
-
-
-
-
@@ -549,26 +532,6 @@ function RuleFields({ rule, rules, setShow, setKeyword }) {
{showMore && (
<>
-
- {OPT_LANGS_TO.map(([langKey, langName]) => (
-
- ))}
-
-
{i18n("secondary_context_menus")}
+
+
+
+
+
+
{OPT_LANGDETECTOR_ALL.map((item) => (
@@ -317,6 +334,25 @@ export default function Settings() {
+
+ {OPT_LANGS_TO.map(([langKey, langName]) => (
+
+ ))}
+
+
{isExt ? (
<>