-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It needs to have C locale for it's execution due to code relying on locale dependant functions for parsing trained data (eg. sscanf). This is really a workaround, but given that tesseract 4.0 is shipped with upcoming Debian stable, we will have to live with this for quite some time. Fixes #2581 Signed-off-by: Michal Čihař <[email protected]>
- Loading branch information
Showing
3 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright © 2012 - 2019 Michal Čihař <[email protected]> | ||
# | ||
# This file is part of Weblate <https://weblate.org/> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
from __future__ import absolute_import | ||
|
||
from locale import setlocale, getlocale, LC_ALL | ||
from contextlib import contextmanager | ||
|
||
|
||
@contextmanager | ||
def c_locale(): | ||
"""Context to execute something in C locale.""" | ||
try: | ||
currlocale = getlocale() | ||
except ValueError: | ||
currlocale = ('C', 'UTF-8') | ||
setlocale(LC_ALL, "C") | ||
yield | ||
setlocale(LC_ALL, currlocale) |