[UI] Move and rename util/lang to translations_util

- The name needed to be more descriptive of it's function.
 - Moved into ui directory because of upcoming  changes being made to setup.py
   meant it would be easier to include all the 'common' ui files if there
   are no sub-dirs such as 'util'.
This commit is contained in:
Calum Lind 2016-11-27 21:32:32 +00:00
parent a924cb73b0
commit 37d9e1f8fe
15 changed files with 28 additions and 28 deletions

View File

@ -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()

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'])

View File

@ -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__)

View File

@ -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.

View File

@ -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

View File

@ -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):

View File

@ -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())

View File

@ -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()

View File

@ -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