Bläddra i källkod

move gettext initialization into the newly created helpers module

Helmut Pozimski 6 år sedan
förälder
incheckning
e7819cdd00
2 ändrade filer med 4 tillägg och 25 borttagningar
  1. 1 1
      lib_stov/configuration.py
  2. 3 24
      stov

+ 1 - 1
lib_stov/configuration.py

@@ -1,4 +1,4 @@
-#   This file is part of stov, written by Helmut Pozimski 2012-2015.
+#   This file is part of stov, written by Helmut Pozimski 2012-2017.
 #
 #   stov is free software: you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by

+ 3 - 24
stov

@@ -4,7 +4,7 @@
 #   stov - a program to subscribe to channels and users from youtube
 #   and download the videos automatically
 #
-#   written by Helmut Pozimski 2012-2015
+#   written by Helmut Pozimski 2012-2017
 #
 #   This program is free software; you can redistribute it and/or
 #   modify it under the terms of the GNU General Public License
@@ -26,7 +26,6 @@ everything together, performing all the actions a user wants.
 """
 
 import sys
-import gettext
 import os
 import smtplib
 import subprocess
@@ -40,30 +39,10 @@ from lib_stov import subscription
 from lib_stov import configuration
 from lib_stov import stov_exceptions
 from lib_stov import database
+from lib_stov import helpers
 
 
-# Determine the path where the stov files are for localization
-
-LOCALE_PATH = os.path.join(sys.path[0] + "/locale")
-if gettext.find("stov", LOCALE_PATH) is None:
-    BASE_PATH = os.path.split(sys.path[0])[0]
-    if "share" in BASE_PATH:
-        LOCALE_PATH = os.path.join(BASE_PATH, "locale")
-    else:
-        LOCALE_PATH = os.path.join(BASE_PATH, "share/locale")
-
-# Initialize gettext to support translation of the program
-
-try:
-    TRANS = gettext.translation("stov", LOCALE_PATH)
-except IOError:
-    gettext.install("stov")
-    if os.environ["LANG"] != "C" and os.environ["LANGUAGE"] != "C":
-        print(_("The translation files could not be found, localization "
-                "won't be available"), file=sys.stderr)
-else:
-    TRANS.install()
-
+helpers.initialize_gettext()
 # Define a handler for signals sent to the program