Skip to content

fix: handle unrecognized language codes gracefully#236

Open
gwuen wants to merge 1 commit intoTenderOwl:masterfrom
gwuen:fix/unrecognized-lang-codes
Open

fix: handle unrecognized language codes gracefully#236
gwuen wants to merge 1 commit intoTenderOwl:masterfrom
gwuen:fix/unrecognized-lang-codes

Conversation

@gwuen
Copy link

@gwuen gwuen commented Jun 19, 2025

Previously, the language list would fail to load if the tessdata directory contained any files with unrecognized language codes, as sorting would raise an exception for unknown languages.

The check for valid codes, which was already implemented in get_downloaded_languages(), has been moved to be done earlier in get_downloaded_codes() to prevent these errors. Now, any unrecognized codes are ignored, with a warning message logged to the console.

Previously, the language list would fail to load if the tessdata
directory contained any files with unrecognized language codes, as
sorting would raise an exception for unknown languages.

The check for valid codes, which was already implemented in
`get_downloaded_languages()`, has been moved to be done earlier in
`get_downloaded_codes()` to prevent these errors. Now, any unrecognized
codes are ignored, with a warning message logged to the console.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant