From 0565118a012849b42c16798c93189a44f88e6b26 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Sun, 29 Nov 2020 12:31:42 +0100 Subject: [PATCH] fixed checking the installed languages. --- src/paperless_tesseract/checks.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/paperless_tesseract/checks.py b/src/paperless_tesseract/checks.py index 8a06d7b00..41ea3c9b5 100644 --- a/src/paperless_tesseract/checks.py +++ b/src/paperless_tesseract/checks.py @@ -14,12 +14,21 @@ def get_tesseract_langs(): @register() def check_default_language_available(app_configs, **kwargs): - langs = get_tesseract_langs() + installed_langs = get_tesseract_langs() - if settings.OCR_LANGUAGE not in langs: - return [Error( - f"The default ocr language {settings.OCR_LANGUAGE} is " - f"not installed. Paperless cannot OCR your documents " - f"without it. Please fix PAPERLESS_OCR_LANGUAGE.")] - else: - return [] + if not settings.OCR_LANGUAGE: + return [Warning( + "No OCR language has been specified with PAPERLESS_OCR_LANGUAGE. " + "This means that tesseract will fallback to english." + )] + + specified_langs = settings.OCR_LANGUAGE.split("+") + + for lang in specified_langs: + if lang not in installed_langs: + return [Error( + f"The selected ocr language {lang} is " + f"not installed. Paperless cannot OCR your documents " + f"without it. Please fix PAPERLESS_OCR_LANGUAGE.")] + + return []