Refactor language handling and fix Tesseract OCR integration#8
Merged
louis030195 merged 2 commits intoscreenpipe:mainfrom Oct 17, 2025
Merged
Refactor language handling and fix Tesseract OCR integration#8louis030195 merged 2 commits intoscreenpipe:mainfrom
louis030195 merged 2 commits intoscreenpipe:mainfrom
Conversation
divanshu-go
commented
Oct 17, 2025
Contributor
Author
There was a problem hiding this comment.
Why it failed:
Language::English(enum variant) was being compared to"english"(string)- The
PartialEq<&str>implementation used theDisplaytrait, which returns ISO codes like"en"(not"english") - So
Language::English == "english"compared"en" == "english"→ alwaysfalse - When languages were specified, the filter returned empty results (no matches found)
- Tesseract got called with
-l(empty language parameter) - Tesseract segfaulted when given an invalid language argument
Now when you specify languages, Tesseract gets proper language codes like -l eng+fra+deu instead of crashing with -l . The macro system ensures type-safe, compile-time guaranteed language mappings with no runtime string operations.
Contributor
Author
Contributor
|
awesome |
Contributor
Author
|
@louis030195 any tip on this one. |
Contributor
|
we don't use OCR, nor linux, so it's not very useful to us @divanshu-go |
Contributor
Author
|
no problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Introduce macro-based
Languageenum with ISO and Tesseract codesReplaces old enum + TESSERACT_LANGUAGES array
Compile-time mapping ensures type safety
Supports optional Tesseract codes for unsupported languages
Build language string in O(n) instead of nested searches
Eliminates brittle string matching and formatting
Before
After