-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: move locale configuration into function for testability
- Loading branch information
1 parent
f6dec8c
commit 8f64192
Showing
4 changed files
with
34 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1 @@ | ||
import gettext | ||
import locale | ||
import os | ||
|
||
|
||
# Configure locale and language. | ||
# Define where the translation assets are to be found. | ||
localedir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'locale')) | ||
try: | ||
# Use the operating system's locale. | ||
current_locale, encoding = locale.getdefaultlocale() | ||
# Get the language code. | ||
if current_locale is None: | ||
language_code = 'en' | ||
else: | ||
language_code = current_locale[:2] | ||
except ValueError: # pragma: no cover | ||
language_code = 'en' # pragma: no cover | ||
# DEBUG/TRANSLATE: override the language code here (e.g. to Chinese). | ||
# language_code = 'zh' | ||
gettext.translation('securedrop_client', localedir=localedir, | ||
languages=[language_code], fallback=True).install() | ||
|
||
|
||
__version__ = '0.0.6' |
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