Skip to content

Commit

Permalink
Refactor extract default language to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo-bulnes committed Oct 15, 2021
1 parent 86e18f9 commit c7d10b5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
from securedrop_client.logic import Controller
from securedrop_client.utils import safe_mkdir

LanguageCode = NewType("LanguageCode", str)

SDC_NAME = "SecureDrop Client"
DEFAULT_SDC_HOME = "~/.securedrop_client"
DEFAULT_LANGUAGE = LanguageCode("en")
ENCODING = "utf-8"
LOGLEVEL = os.environ.get("LOGLEVEL", "info").upper()

LanguageCode = NewType("LanguageCode", str)


def init(sdc_home: str) -> None:
safe_mkdir(sdc_home)
Expand All @@ -70,11 +71,11 @@ def configure_locale_and_language() -> LanguageCode:
current_locale, encoding = locale.getdefaultlocale()
# Get the language code.
if current_locale is None:
code = LanguageCode("en")
code = DEFAULT_LANGUAGE
else:
code = LanguageCode(current_locale[:2])
except ValueError: # pragma: no cover
code = LanguageCode("en") # pragma: no cover
code = DEFAULT_LANGUAGE # pragma: no cover
gettext.bindtextdomain("messages", localedir=localedir)
gettext.textdomain("messages")
return code
Expand Down

0 comments on commit c7d10b5

Please sign in to comment.