🎨 Re OCR popup prompt when Tesseract is not enabled https://github.com/siyuan-note/siyuan/issues/15367

This commit is contained in:
Daniel 2025-07-25 19:34:35 +08:00
parent 7787ac6e1d
commit 70741fffcc
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
15 changed files with 40 additions and 15 deletions

View file

@ -1642,6 +1642,7 @@
"262": "غدًا", "262": "غدًا",
"263": "التالي %d أيام", "263": "التالي %d أيام",
"264": "الحقل [%s] فارغ", "264": "الحقل [%s] فارغ",
"265": "خارج النطاق" "265": "خارج النطاق",
"266": "Tesseract OCR غير مثبت أو غير مهيأ، يرجى الرجوع إلى دليل المستخدم - قسم ملفات الموارد لإجراء الإعداد"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Morgen", "262": "Morgen",
"263": "Nächste %d Tage", "263": "Nächste %d Tage",
"264": "Das Feld [%s] ist leer", "264": "Das Feld [%s] ist leer",
"265": "Außerhalb des Bereichs" "265": "Außerhalb des Bereichs",
"266": "Tesseract OCR ist nicht installiert oder konfiguriert, bitte lesen Sie das Benutzerhandbuch - Abschnitt Ressourcen-Dateien zur Konfiguration"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Tomorrow", "262": "Tomorrow",
"263": "Next %d days", "263": "Next %d days",
"264": "Field [%s] is empty", "264": "Field [%s] is empty",
"265": "Out of range" "265": "Out of range",
"266": "Tesseract OCR is not installed or configured, please refer to the User Guide - Assets section for configuration"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Mañana", "262": "Mañana",
"263": "Próximos %d días", "263": "Próximos %d días",
"264": "El campo [%s] está vacío", "264": "El campo [%s] está vacío",
"265": "Fuera de rango" "265": "Fuera de rango",
"266": "Tesseract OCR no está instalado o configurado, consulte la Guía del Usuario - Sección de archivos de recursos para la configuración"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Demain", "262": "Demain",
"263": "Les %d prochains jours", "263": "Les %d prochains jours",
"264": "Le champ [%s] est vide", "264": "Le champ [%s] est vide",
"265": "Hors de portée" "265": "Hors de portée",
"266": "Tesseract OCR n'est pas installé ou configuré, veuillez consulter le Guide de l'utilisateur - Section des fichiers de ressources pour la configuration"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "מחר", "262": "מחר",
"263": "ה-%d ימים הבאים", "263": "ה-%d ימים הבאים",
"264": "השדה [%s] ריק", "264": "השדה [%s] ריק",
"265": "מחוץ לטווח" "265": "מחוץ לטווח",
"266": "Tesseract OCR לא הותקן או הוגדר, אנא עיין במדריך למשתמש - פרק קבצי משאבים לצורך הגדרה"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Domani", "262": "Domani",
"263": "Prossimi %d giorni", "263": "Prossimi %d giorni",
"264": "Il campo [%s] è vuoto", "264": "Il campo [%s] è vuoto",
"265": "Fuori intervallo" "265": "Fuori intervallo",
"266": "Tesseract OCR non è installato o configurato, fare riferimento alla Guida utente - Sezione file di risorse per la configurazione"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "明日", "262": "明日",
"263": "次の %d 日間", "263": "次の %d 日間",
"264": "フィールド [%s] の値が空です", "264": "フィールド [%s] の値が空です",
"265": "範囲外" "265": "範囲外",
"266": "Tesseract OCR がインストールされていないか、設定されていません。ユーザーガイド - リソースファイルセクションを参照して設定してください"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Jutro", "262": "Jutro",
"263": "Następne %d dni", "263": "Następne %d dni",
"264": "Pole [%s] jest puste", "264": "Pole [%s] jest puste",
"265": "Poza zakresem" "265": "Poza zakresem",
"266": "Tesseract OCR nie jest zainstalowany lub skonfigurowany, zapoznaj się z Podręcznikiem użytkownika - Sekcja plików zasobów, aby skonfigurować"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Amanhã", "262": "Amanhã",
"263": "Próximos %d dias", "263": "Próximos %d dias",
"264": "O campo [%s] está vazio", "264": "O campo [%s] está vazio",
"265": "Fora do intervalo" "265": "Fora do intervalo",
"266": "Tesseract OCR não está instalado ou configurado, consulte o Guia do Usuário - Seção de Arquivos de Recursos para configuração"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "Завтра", "262": "Завтра",
"263": "Следующие %d дней", "263": "Следующие %d дней",
"264": "Поле [%s] имеет пустое значение", "264": "Поле [%s] имеет пустое значение",
"265": "Вне диапазона" "265": "Вне диапазона",
"266": "Tesseract OCR не установлен или не настроен, пожалуйста, обратитесь к Руководству пользователя - Раздел ресурсов для настройки"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "明天", "262": "明天",
"263": "未來 %d 天", "263": "未來 %d 天",
"264": "字段 [%s] 值為空", "264": "字段 [%s] 值為空",
"265": "不在範圍內" "265": "不在範圍內",
"266": "Tesseract OCR 未安裝或未配置,請參考 使用者指南-資料文件 章節進行配置"
} }
} }

View file

@ -1642,6 +1642,7 @@
"262": "明天", "262": "明天",
"263": "未来 %d 天", "263": "未来 %d 天",
"264": "字段 [%s] 值为空", "264": "字段 [%s] 值为空",
"265": "不在范围内" "265": "不在范围内",
"266": "Tesseract OCR 未安装或未配置,请参考 用户指南-资源文件 章节进行配置"
} }
} }

View file

@ -153,7 +153,14 @@ func ocr(c *gin.Context) {
path := arg["path"].(string) path := arg["path"].(string)
ocrJSON := util.OcrAsset(path) ocrJSON, err := util.OcrAsset(path)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
ret.Data = map[string]interface{}{"closeTimeout": 7000}
return
}
ret.Data = map[string]interface{}{ ret.Data = map[string]interface{}{
"text": util.GetOcrJsonText(ocrJSON), "text": util.GetOcrJsonText(ocrJSON),
"ocrJSON": ocrJSON, "ocrJSON": ocrJSON,

View file

@ -149,7 +149,12 @@ func ExistsAssetText(asset string) (ret bool) {
return return
} }
func OcrAsset(asset string) (ret []map[string]interface{}) { func OcrAsset(asset string) (ret []map[string]interface{}, err error) {
if !TesseractEnabled {
err = fmt.Errorf(Langs[Lang][266])
return
}
assetsPath := GetDataAssetsAbsPath() assetsPath := GetDataAssetsAbsPath()
assetAbsPath := strings.TrimPrefix(asset, "assets") assetAbsPath := strings.TrimPrefix(asset, "assets")
assetAbsPath = filepath.Join(assetsPath, assetAbsPath) assetAbsPath = filepath.Join(assetsPath, assetAbsPath)