Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese translation jessie #193

Open
wants to merge 14 commits into
base: jessie
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/kano-updater
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def run_install_ind_pkg(package):

def main():
msg = _('Administrator priviledges are required to perform this operation')
enforce_root("{}: {}".format(_('ERROR'), msg))
enforce_root(u"{}: {}".format(_('ERROR'), msg))

# docopt wasn't installed by default prior Kano OS 1.3.3
# It needs to be installed to make sure the updater runs
Expand All @@ -166,7 +166,7 @@ def main():
if not args['relaunch-splash'] and is_running():
msg = _('An instance of Kano Updater is already running')
logger.error(msg)
sys.stderr.write("{}: {}\n".format(_('ERROR'), msg))
sys.stderr.write(u"{}: {}\n".format(_('ERROR'), msg))
sys.exit(1)

# This is registered after the test for whether an updater was already
Expand Down
12 changes: 7 additions & 5 deletions kano_updater/apt_progress_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import apt

from kano_updater.progress import Phase
from kano_updater.i18n import to_unicode


class AptDownloadProgress(apt.progress.base.AcquireProgress):
Expand All @@ -36,11 +37,11 @@ def fetch(self, item_desc):

def done(self, item_desc):
super(AptDownloadProgress, self).done(item_desc)
msg = "Downloading {}".format(item_desc.shortdesc)
msg = _("Downloading {}").format(item_desc.shortdesc)

# Show the long description too if it's not too long
if len(item_desc.description) < 40:
msg = "{} {}".format(msg, item_desc.description)
msg = u"{} {}".format(msg, item_desc.description)

self._updater_progress.next_step(self._phase_name, msg)

Expand Down Expand Up @@ -71,9 +72,10 @@ def __init__(self, updater_progress, ops=[]):
self._updater_progress.init_steps(op, 100)

def _get_op_key(self, op_name):
template = "{prefix}-{{}}".format(prefix=self._phase_name)
template = u"{prefix}-{{}}".format(prefix=self._phase_name)

return template.format(op_name).lower().replace(' ', '-')
op_name = to_unicode(op_name)
return template.format(op_name).lower().replace(u' ', u'-')

def _next_phase(self):
if len(self._ops) <= 1:
Expand Down Expand Up @@ -106,7 +108,7 @@ def conffile(self, current, new):
print 'conffile', current, new

def error(self, pkg, errormsg):
self._updater_progress.fail("{}: {}".format(pkg, errormsg))
self._updater_progress.fail(u"{}: {}".format(pkg, errormsg))

def processing(self, pkg, stage):
print 'processing', pkg, stage
Expand Down
29 changes: 17 additions & 12 deletions kano_updater/apt_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import apt
import aptsources.sourceslist
import apt_pkg
import gettext

from kano.logging import logger
from kano.utils import run_cmd_log
Expand All @@ -19,6 +20,10 @@
import kano_updater.priority as Priority
from kano_updater.special_packages import independent_install_list


def apt_gettext(msg):
return gettext.dgettext('python-apt', msg)

class AptWrapper(object):
def __init__(self):
apt.apt_pkg.init_config()
Expand All @@ -41,9 +46,9 @@ def update(self, progress, sources_list=None):
if not src.disabled and not src.invalid:
src_count += len(src.comps) + 1

updating_sources = "{}-updating-apt-sources".format(
updating_sources = u"{}-updating-apt-sources".format(
progress.get_current_phase().name)
cache_init = "{}-apt-cache-init".format(
cache_init = u"{}-apt-cache-init".format(
progress.get_current_phase().name)
progress.split(
Phase(updating_sources, _('Updating apt sources')),
Expand All @@ -61,8 +66,8 @@ def update(self, progress, sources_list=None):
progress.fail(_(err_msg))

progress.start(cache_init)
ops = [_('Reading package lists'), _('Building dependency tree'),
_('Reading state information'), _('Building data structures')]
ops = [apt_gettext('Reading package lists'), apt_gettext('Building dependency tree'),
apt_gettext('Reading state information'), apt_gettext('Building data structures')]
op_progress = AptOpProgress(progress, ops)
self._cache.open(op_progress)

Expand Down Expand Up @@ -114,11 +119,11 @@ def upgrade(self, packages, progress=None, priority=Priority.NONE):
pkg.mark_upgrade()

phase_name = progress.get_current_phase().name
download = "{}-downloading".format(phase_name)
install = "{}-installing".format(phase_name)
download = u"{}-downloading".format(phase_name)
install = u"{}-installing".format(phase_name)
progress.split(
Phase(download, "Downloading packages"),
Phase(install, "Installing packages")
Phase(download, _("Downloading packages")),
Phase(install, _("Installing packages"))
)

progress.start(download)
Expand All @@ -141,11 +146,11 @@ def upgrade_all(self, progress=None, priority=Priority.NONE):
self._cache.upgrade(dist_upgrade=True)

phase_name = progress.get_current_phase().name
download = "{}-downloading".format(phase_name)
install = "{}-installing".format(phase_name)
download = u"{}-downloading".format(phase_name)
install = u"{}-installing".format(phase_name)
progress.split(
Phase(download, "Downloading packages"),
Phase(install, "Installing packages")
Phase(download, _("Downloading packages")),
Phase(install, _("Installing packages"))
)

progress.start(download)
Expand Down
26 changes: 13 additions & 13 deletions kano_updater/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def download(progress=None, gui=True):
# show a dialog informing the user of an automatic urgent download
if status.is_urgent and not gui:
# TODO: mute notifications?
title = "Updater"
description = "Kano HQ has just released a critical update that will repair" \
" some important things on your system! We'll download these automatically," \
" and ask you to schedule the install when they finish."
buttons = "OK:green:1"
title = _("Updater")
description = _("Kano HQ has just released a critical update that will repair" +\
" some important things on your system! We'll download these automatically," +\
" and ask you to schedule the install when they finish.")
buttons = _("OK:green:1")
dialog_proc = show_kano_dialog(title, description, buttons, blocking=False)

status.state = UpdaterStatus.DOWNLOADING_UPDATES
Expand All @@ -101,10 +101,10 @@ def download(progress=None, gui=True):

if status.is_urgent:
priority = Priority.URGENT
logger.info('Urgent update detected, bumping to normal priority')
logger.info(u'Urgent update detected, bumping to normal priority')
make_normal_prio()

logger.debug('Downloading with priority {}'.format(priority.priority))
logger.debug(u'Downloading with priority {}'.format(priority.priority))

try:
success = do_download(progress, status, priority=priority, dialog_proc=dialog_proc)
Expand All @@ -127,19 +127,19 @@ def do_download(progress, status, priority=Priority.NONE, dialog_proc=None):
progress.split(
Phase(
'downloading-pip-pkgs',
'Downloading Python packages',
_('Downloading Python packages'),
10,
is_main=True
),
Phase(
'updating-sources',
'Updating apt sources',
_('Updating apt sources'),
40,
is_main=True
),
Phase(
'downloading-apt-packages',
'Downloading apt packages',
_('Downloading apt packages'),
50,
is_main=True
)
Expand All @@ -148,7 +148,7 @@ def do_download(progress, status, priority=Priority.NONE, dialog_proc=None):
_cache_pip_packages(progress, priority=priority)
_cache_deb_packages(progress, priority=priority)

progress.finish('Done downloading')
progress.finish(_('Done downloading'))

# kill the dialog if it is still on
if dialog_proc:
Expand Down Expand Up @@ -177,7 +177,7 @@ def _cache_pip_packages(progress, priority=Priority.NONE):
progress.init_steps(phase_name, len(packages))

for pkg in packages:
progress.next_step(phase_name, "Downloading {}".format(pkg))
progress.next_step(phase_name, _("Downloading {}").format(pkg))

# The `--no-install` parameter has been deprecated in pip. However, the
# version of pip in wheezy doesn't yet support the new approach which
Expand All @@ -187,7 +187,7 @@ def _cache_pip_packages(progress, priority=Priority.NONE):

# TODO: abort the install?
if not success:
msg = "Downloading the '{}' pip package failed.".format(pkg)
msg = _("Downloading the '{}' pip package failed.").format(pkg)
logger.error(msg)


Expand Down
38 changes: 19 additions & 19 deletions kano_updater/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class InstallError(Exception):

def install(progress=None, gui=True):
status = UpdaterStatus.get_instance()
logger.debug("Installing update (updater state = {})".format(status.state))
logger.debug(u"Installing update (updater state = {})".format(status.state))

if not progress:
progress = DummyProgress()
Expand All @@ -46,11 +46,11 @@ def install(progress=None, gui=True):
# TODO: Take this value from apt
mb_free = get_free_space()
if mb_free < 1024:
err_msg = _("Only {}MB free, at least 1GB is needed.".format(mb_free))
err_msg = _("Only {}MB free, at least 1GB is needed.").format(mb_free)
logger.warn(err_msg)
answer = progress.prompt(
'Not enough space to update!',
'But I can make more room if you\'d like?',
_('Not enough space to update!'),
_('But I can make more room if you\'d like?'),
['OK', 'CANCEL']
)

Expand Down Expand Up @@ -103,7 +103,7 @@ def install(progress=None, gui=True):
if status.is_urgent:
priority = Priority.URGENT

logger.debug('Installing with priority {}'.format(priority.priority))
logger.debug(u'Installing with priority {}'.format(priority.priority))

try:
return do_install(progress, status, priority=priority)
Expand Down Expand Up @@ -140,7 +140,7 @@ def do_install(progress, status, priority=Priority.NONE):
status.is_scheduled = False
status.save()

progress.finish('Update completed')
progress.finish(_('Update completed'))
return True

def install_ind_package(progress, package):
Expand All @@ -153,16 +153,16 @@ def install_ind_package(progress, package):
if status.state not in [UpdaterStatus.NO_UPDATES,
UpdaterStatus.UPDATES_AVAILABLE,
UpdaterStatus.UPDATES_INSTALLED]:
msg = 'The install is already running'
msg = N_('The install is already running')
logger.warn(msg)
progress.abort(_(msg))
return False

if package not in status.updatable_independent_packages:
msg = 'tried to install non-independent package {} using update_ind_pkg'.format(package)
logger.warn(msg)
progress.abort(_(msg))
return False
msg = N_('tried to install non-independent package {} using update_ind_pkg')
logger.warn(msg.format(package))
progress.abort(_(msg).format(package))
return False

status.state = UpdaterStatus.INSTALLING_INDEPENDENT
status.save()
Expand Down Expand Up @@ -197,7 +197,7 @@ def install_ind_package(progress, package):
status.is_scheduled = False
status.save()

progress.finish('Update completed')
progress.finish(_('Update completed'))
return True


Expand Down Expand Up @@ -268,7 +268,7 @@ def install_standard(progress, status):
),
Phase(
'aux-tasks',
'Performing auxiliary tasks',
_('Performing auxiliary tasks'),
10,
is_main=True
)
Expand All @@ -281,7 +281,7 @@ def install_standard(progress, status):
# determine the versions (from and to)
system_version = OSVersion.from_version_file(SYSTEM_VERSION_FILE)

msg = "Upgrading from {} to {}".format(system_version, TARGET_VERSION)
msg = u"Upgrading from {} to {}".format(system_version, TARGET_VERSION)
logger.info(msg)

# set up the scenarios and check whether they cover updating
Expand All @@ -294,7 +294,7 @@ def install_standard(progress, status):
description = _('You will need to download the image of the '
'OS and reflash your SD card.')

msg = "{}: {}".format(title, description)
msg = u"{}: {}".format(title, description)
logger.error("Updating from a version that is no longer supported ({})"
.format(system_version))
progress.fail(msg)
Expand Down Expand Up @@ -365,18 +365,18 @@ def install_pip_packages(progress, priority=Priority.NONE):
progress.init_steps(phase_name, len(packages))

for pkg in packages:
progress.next_step(phase_name, "Installing {}".format(pkg))
progress.next_step(phase_name, _("Installing {}").format(pkg))

success = run_pip_command(
"install --upgrade --no-index --find-links=file://{} '{}'".format(
PIP_CACHE_DIR, pkg)
)

if not success:
msg = "Installing the '{}' pip package failed".format(pkg)
msg = u"Installing the '{}' pip package failed".format(pkg)
logger.error(msg)
if not is_internet():
msg = "Network is down, aborting PIP install"
msg = u"Network is down, aborting PIP install"
logger.error(msg)
raise IOError(msg)

Expand All @@ -385,6 +385,6 @@ def install_pip_packages(progress, priority=Priority.NONE):
"install --upgrade '{}'".format(pkg)
)
if not success_failsafe:
msg = "Installing the '{}' pip package failed (fsafe)".format(
msg = u"Installing the '{}' pip package failed (fsafe)".format(
pkg)
logger.error(msg)
12 changes: 12 additions & 0 deletions kano_updater/i18n.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# i18n.py
#
# Copyright (C) 2016 Kano Computing Ltd.
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# I18n helpers for the updater

def to_unicode(string):
if type(string).__name__ == "str":
return string.decode('utf-8')
return string

Loading