From 33bc669591f1c3f7ca25cb33e66d9ffeeb8b064d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 9 Aug 2017 18:08:35 +0900 Subject: [PATCH] Python-i18n: trivial example adding _ to python jobs - add to dummypython - also add to machineid --- src/modules/dummypython/main.py | 28 ++++++++++++++++++++++++++-- src/modules/machineid/main.py | 10 +++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/modules/dummypython/main.py b/src/modules/dummypython/main.py index 7cca65109..19afa8302 100644 --- a/src/modules/dummypython/main.py +++ b/src/modules/dummypython/main.py @@ -5,6 +5,7 @@ # # Copyright 2014, Teo Mrnjavac # Copyright 2017, Alf Gaida +# Copyright 2017, Adriaan de Groot # # Calamares is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,6 +33,14 @@ import libcalamares import os from time import gmtime, strftime, sleep +import gettext +_ = gettext.translation("python", + libcalamares.job.gettext_path, + libcalamares.globalstorage.gettext_languages(), + fallback=True).gettext + +def pretty_name(): + return _("Dummy python job.") def run(): """Dummy python job.""" @@ -65,11 +74,26 @@ def run(): str(libcalamares.globalstorage.value("foo")), str(libcalamares.globalstorage.value("item2")), str(libcalamares.globalstorage.value("item3"))) - - libcalamares.job.setprogress(0.1) libcalamares.utils.debug(accumulator) + libcalamares.utils.debug("Run dummy python") + + sleep(1) + + try: + l = list(libcalamares.job.configuration["a_list"]) + except KeyError: + l = ["no list"] + + c = 1 + for k in l: + libcalamares.utils.debug(_("Dummy python step {}").format(str(k))) + sleep(1) + libcalamares.job.setprogress( c * 1.0 / len(l) ) + c += 1 + sleep(3) + # To indicate an error, return a tuple of: # (message, detailed-error-message) return None diff --git a/src/modules/machineid/main.py b/src/modules/machineid/main.py index 7d0ac2c54..cd4f06504 100644 --- a/src/modules/machineid/main.py +++ b/src/modules/machineid/main.py @@ -22,8 +22,16 @@ import libcalamares import os -from libcalamares.utils import check_target_env_call +from libcalamares.utils import check_target_env_call, debug +import gettext +_ = gettext.translation("python", + libcalamares.job.gettext_path, + libcalamares.globalstorage.gettext_languages(), + fallback=True).gettext + +def pretty_name(): + return _("Generate machine-id.") def run(): """