diff --git a/deluge/core/daemon_entry.py b/deluge/core/daemon_entry.py index cccc50588..2bec8bb4c 100644 --- a/deluge/core/daemon_entry.py +++ b/deluge/core/daemon_entry.py @@ -16,7 +16,7 @@ from logging import FileHandler, getLogger from deluge.common import run_profiled from deluge.configmanager import get_config_dir from deluge.ui.baseargparser import BaseArgParser -from deluge.ui.util import lang +from deluge.ui.translations_util import set_dummy_trans def add_daemon_options(parser): @@ -43,7 +43,7 @@ def start_daemon(skip_start=False): deluge.core.daemon.Daemon: A new daemon object """ - lang.set_dummy_trans(warn_msg=True) + set_dummy_trans(warn_msg=True) # Setup the argument parser parser = BaseArgParser() diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 092290360..a29865f9f 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -23,7 +23,7 @@ import deluge.configmanager import deluge.core.preferencesmanager import deluge.log from deluge.error import DelugeError -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations # This sets log level to critical, so use log.critical() to debug while running unit tests deluge.log.setup_logger('none') @@ -76,7 +76,7 @@ def add_watchdog(deferred, timeout=0.05, message=None): # Initialize gettext -lang.setup_translations() +setup_translations() class ReactorOverride(object): diff --git a/deluge/tests/test_common.py b/deluge/tests/test_common.py index b7e813a0f..285785678 100644 --- a/deluge/tests/test_common.py +++ b/deluge/tests/test_common.py @@ -4,12 +4,12 @@ from twisted.trial import unittest from deluge.common import (VersionSplit, fdate, fpcnt, fpeer, fsize, fspeed, ftime, get_path_size, is_infohash, is_ip, is_ipv4, is_ipv6, is_magnet, is_url) -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations class CommonTestCase(unittest.TestCase): def setUp(self): # NOQA - lang.setup_translations() + setup_translations() def tearDown(self): # NOQA pass diff --git a/deluge/tests/test_files_tab.py b/deluge/tests/test_files_tab.py index 51a3684ba..9704b124f 100644 --- a/deluge/tests/test_files_tab.py +++ b/deluge/tests/test_files_tab.py @@ -5,7 +5,7 @@ from twisted.trial import unittest import deluge.component as component from deluge.configmanager import ConfigManager -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations from . import common from .basetest import BaseTestCase @@ -22,7 +22,7 @@ except ImportError as err: import traceback traceback.print_exc() -lang.setup_translations() +setup_translations() @pytest.mark.gtkui diff --git a/deluge/tests/test_torrentview.py b/deluge/tests/test_torrentview.py index 0bee72802..a60f5b2de 100644 --- a/deluge/tests/test_torrentview.py +++ b/deluge/tests/test_torrentview.py @@ -3,7 +3,7 @@ from twisted.trial import unittest import deluge.component as component from deluge.configmanager import ConfigManager -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations from . import common from .basetest import BaseTestCase @@ -24,7 +24,7 @@ else: from deluge.ui.gtkui.torrentview import TorrentView from deluge.ui.gtkui.gtkui import DEFAULT_PREFS -lang.setup_translations() +setup_translations() @pytest.mark.gtkui diff --git a/deluge/ui/console/modes/preferences/preference_panes.py b/deluge/ui/console/modes/preferences/preference_panes.py index 2801ff1ff..2f00ed284 100644 --- a/deluge/ui/console/modes/preferences/preference_panes.py +++ b/deluge/ui/console/modes/preferences/preference_panes.py @@ -159,8 +159,8 @@ class InterfacePane(BasePreferencePane): console_config['torrentview']['separate_complete']) self.add_checked_input('move_selection', _('Move selection when moving torrents in the queue'), console_config['torrentview']['move_selection']) - from deluge.ui.util import lang - langs = lang.get_languages() + from deluge.ui.translations_util import get_languages + langs = get_languages() langs.insert(0, ('', 'System Default')) self.add_combo_input('language', _('Language'), langs, default=console_config['language']) diff --git a/deluge/ui/console/utils/column.py b/deluge/ui/console/utils/column.py index ab63875bc..8163bdcf8 100644 --- a/deluge/ui/console/utils/column.py +++ b/deluge/ui/console/utils/column.py @@ -12,11 +12,11 @@ import logging import deluge.common from deluge.ui.common import TORRENT_DATA_FIELD -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations from . import format_utils -lang.setup_translations() +setup_translations() log = logging.getLogger(__name__) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 3a8003e4c..76ba39932 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -59,7 +59,7 @@ from deluge.ui.gtkui.torrentdetails import TorrentDetails from deluge.ui.gtkui.torrentview import TorrentView from deluge.ui.sessionproxy import SessionProxy from deluge.ui.tracker_icons import TrackerIcons -from deluge.ui.util import lang +from deluge.ui.translations_util import set_language, setup_translations set_prgname('deluge') log = logging.getLogger(__name__) @@ -139,7 +139,7 @@ DEFAULT_PREFS = { class GtkUI(object): def __init__(self, args): # Setup gtkbuilder/glade translation - lang.setup_translations(setup_gettext=False, setup_pygtk=True) + setup_translations(setup_gettext=False, setup_pygtk=True) # Setup signals def on_die(*args): @@ -172,7 +172,7 @@ class GtkUI(object): # Set language if self.config['language'] is not None: - lang.set_language(self.config['language']) + set_language(self.config['language']) # Start the IPC Interface before anything else.. Just in case we are # already running. diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 82cc04f38..cdcc1716c 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -23,7 +23,7 @@ from deluge.ui.client import client from deluge.ui.gtkui.common import associate_magnet_links, get_deluge_icon from deluge.ui.gtkui.dialogs import AccountDialog, ErrorDialog, InformationDialog, YesNoDialog from deluge.ui.gtkui.path_chooser import PathChooser -from deluge.ui.util import lang +from deluge.ui.translations_util import get_languages try: import appindicator @@ -186,7 +186,7 @@ class Preferences(component.Component): self.language_combo = self.builder.get_object('combobox_language') self.language_checkbox = self.builder.get_object('checkbutton_language') lang_model = self.language_combo.get_model() - langs = lang.get_languages() + langs = get_languages() index = -1 for i, l in enumerate(langs): lang_code, name = l diff --git a/deluge/ui/util/lang.py b/deluge/ui/translations_util.py similarity index 100% rename from deluge/ui/util/lang.py rename to deluge/ui/translations_util.py diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index cb7076098..07e2dbc11 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -13,7 +13,7 @@ import deluge.common import deluge.configmanager import deluge.log from deluge.ui.baseargparser import BaseArgParser -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations log = logging.getLogger(__name__) @@ -34,7 +34,7 @@ class UI(object): def __init__(self, name, **kwargs): self.__name = name self.ui_args = kwargs.pop('ui_args', None) - lang.setup_translations() + setup_translations() self.__parser = BaseArgParser(**kwargs) def parse_args(self, parser, args=None): diff --git a/deluge/ui/ui_entry.py b/deluge/ui/ui_entry.py index 2474fe581..cd3a130c8 100644 --- a/deluge/ui/ui_entry.py +++ b/deluge/ui/ui_entry.py @@ -23,7 +23,7 @@ import pkg_resources import deluge.common import deluge.configmanager from deluge.ui.baseargparser import BaseArgParser -from deluge.ui.util import lang +from deluge.ui.translations_util import setup_translations DEFAULT_PREFS = { 'default_ui': 'gtk' @@ -34,7 +34,7 @@ AMBIGUOUS_CMD_ARGS = ('-h', '--help', '-v', '-V', '--version') def start_ui(): """Entry point for ui script""" - lang.setup_translations() + setup_translations() # Get the registered UI entry points ui_entrypoints = dict([(entrypoint.name, entrypoint.load()) diff --git a/deluge/ui/util/__init__.py b/deluge/ui/util/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 150a68bbb..99d823666 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -29,7 +29,7 @@ from deluge.ui import common as uicommon from deluge.ui.client import Client, client from deluge.ui.coreconfig import CoreConfig from deluge.ui.sessionproxy import SessionProxy -from deluge.ui.util import lang +from deluge.ui.translations_util import get_languages from deluge.ui.web.common import _, compress log = logging.getLogger(__name__) @@ -995,4 +995,4 @@ class WebUtils(JSONComponent): Returns: list: of tuples [(lang-id, language-name), ...] """ - return lang.get_languages() + return get_languages() diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 00c72ebef..15b807847 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -24,7 +24,7 @@ from deluge import common, component, configmanager from deluge.common import is_ipv6 from deluge.core.rpcserver import check_ssl_keys from deluge.ui.tracker_icons import TrackerIcons -from deluge.ui.util import lang +from deluge.ui.translations_util import set_language, setup_translations from deluge.ui.web.auth import Auth from deluge.ui.web.common import Template, compress from deluge.ui.web.json_api import JSON, WebApi, WebUtils @@ -581,7 +581,7 @@ class DelugeWeb(component.Component): # Strip away slashes and serve on the base path as well as root path self.top_level.putChild(self.base.strip('/'), self.top_level) - lang.setup_translations(setup_gettext=True, setup_pygtk=False) + setup_translations(setup_gettext=True, setup_pygtk=False) self.site = server.Site(self.top_level) self.web_api = WebApi() @@ -594,7 +594,7 @@ class DelugeWeb(component.Component): def _on_language_changed(self, key, value): log.debug('Setting UI language %s', value) - lang.set_language(value) + set_language(value) def install_signal_handlers(self): # Since twisted assigns itself all the signals may as well make