feat: optimize language check

This commit is contained in:
DIYgod
2025-01-14 20:23:58 +08:00
parent 3c5dba4d7a
commit f850474d13
+7 -1
View File
@@ -1,3 +1,4 @@
import { parseHtml } from "@follow/components/ui/markdown/parse-html.js"
import { views } from "@follow/constants"
import type { SupportedLanguages } from "@follow/models/types"
@@ -58,7 +59,12 @@ export async function translate({
fields = fields.filter((field) => {
if (language && entry.entries[field]) {
const sourceLanguage = franc(entry.entries[field])
const content = parseHtml(entry.entries[field])
.toText()
.replaceAll(/https?:\/\/\S+|www\.\S+/g, " ")
const sourceLanguage = franc(content, {
only: [LanguageMap[language].code],
})
if (sourceLanguage === LanguageMap[language].code) {
return false