From: Frank Brehm Date: Fri, 8 Feb 2019 09:35:17 +0000 (+0100) Subject: Translating lib/cr_vmware_tpl/app.py X-Git-Tag: 1.1.0^2~7^2~6 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=33672109ddf739b0c41e8902d1e6097b8b9254dd;p=pixelpark%2Fcreate-vmware-tpl.git Translating lib/cr_vmware_tpl/app.py --- diff --git a/lib/cr_vmware_tpl/app.py b/lib/cr_vmware_tpl/app.py index 5b081d1..0629031 100644 --- a/lib/cr_vmware_tpl/app.py +++ b/lib/cr_vmware_tpl/app.py @@ -31,9 +31,17 @@ from .config import CrTplConfiguration from .handler import CrTplHandler -__version__ = '1.0.2' +from .xlate import __module_dir__ as __xlate_module_dir__ +from .xlate import __base_dir__ as __xlate_base_dir__ +from .xlate import __mo_file__ as __xlate_mo_file__ +from .xlate import XLATOR, LOCALE_DIR, DOMAIN + +__version__ = '1.1.0' LOG = logging.getLogger(__name__) +_ = XLATOR.gettext +ngettext = XLATOR.ngettext + # ============================================================================= class CrTplAppError(FbAppError): @@ -56,11 +64,11 @@ class NrTemplatesOptionAction(argparse.Action): def __call__(self, parser, namespace, values, option_string=None): if values < 1: - msg = "Value must be at least 1, {} was given.".format(values) + msg = _("Value must be at least 1, {} was given.").format(values) raise argparse.ArgumentError(self, msg) if values >= self._max: - msg = "Value must be at most {m} - {v} was given.".format( + msg = _("Value must be at most {m} - {v} was given.").format( m=self._max - 1, v=values) raise argparse.ArgumentError(self, msg) @@ -85,10 +93,10 @@ class CfgFileOptionAction(argparse.Action): path = pathlib.Path(values) if not path.exists(): - msg = "File {!r} does not exists.".format(values) + msg = _("File {!r} does not exists.").format(values) raise argparse.ArgumentError(self, msg) if not path.is_file(): - msg = "File {!r} is not a regular file.".format(values) + msg = _("File {!r} is not a regular file.").format(values) raise argparse.ArgumentError(self, msg) setattr(namespace, self.dest, path.resolve()) @@ -109,10 +117,9 @@ class CrTplApplication(BaseApplication): initialized=False, usage=None, description=None, argparse_epilog=None, argparse_prefix_chars='-', env_prefix=None): - desc = textwrap.dedent("""\ - Creates in the given vSphere environment and cluster a template object, - which can be used to spawn different virtual machines. - """).strip() + desc = _( + "Creates in the given VSphere environment and cluster a template object, " + "which can be used to spawn different virtual machines.") self._cfg_file = None self.config = None @@ -145,6 +152,16 @@ class CrTplApplication(BaseApplication): res = super(CrTplApplication, self).as_dict(short=short) res['cfg_file'] = self.cfg_file + if 'xlate' not in res: + res['xlate'] = {} + res['xlate'][DOMAIN] = { + '__module_dir__': __xlate_module_dir__, + '__base_dir__': __xlate_base_dir__, + 'LOCALE_DIR': LOCALE_DIR, + 'DOMAIN': DOMAIN, + '__mo_file__': __xlate_mo_file__, + } + return res # ------------------------------------------------------------------------- @@ -176,12 +193,12 @@ class CrTplApplication(BaseApplication): self.config.initialized = True if self.verbose > 3: - LOG.debug("Read configuration:\n{}".format(pp(self.config.as_dict()))) + LOG.debug(_("Read configuration:") + '\n' + pp(self.config.as_dict())) self.perform_arg_parser_vmware() if not self.config.password: - prompt = 'Enter password for host {h!r} and user {u!r}: '.format( + prompt = (_('Enter password for host {h!r} and user {u!r}:') + ' ').format( h=self.config.vsphere_host, u=self.config.vsphere_user) self.config.password = getpass.getpass(prompt=prompt) @@ -211,62 +228,64 @@ class CrTplApplication(BaseApplication): self.arg_parser.add_argument( '-A', '--abort', dest='abort', action='store_true', - help="Abort creation of VMWare template after successsful creation of template VM.", + help=_( + "Abort creation of VMWare template after successsful creation of template VM."), ) self.arg_parser.add_argument( - '-c', '--config', '--config-file', dest='cfg_file', metavar='FILE', + '-c', '--config', '--config-file', dest='cfg_file', metavar=_('FILE'), action=CfgFileOptionAction, - help="Configuration file (default: {!r})".format(default_cfg_file) + help=_("Configuration file (default: {!r}).").format(str(default_cfg_file)) ) - vmware_group = self.arg_parser.add_argument_group('VMWare options') + vmware_group = self.arg_parser.add_argument_group(_('VMWare options')) vmware_group.add_argument( '-H', '--host', dest='host', - help="Remote vSphere host to connect to (Default: {!r}).".format( + help=_("Remote VSphere host to connect to (Default: {!r}).").format( CrTplConfiguration.default_vsphere_host) ) vmware_group.add_argument( '-p', '--port', dest='port', type=int, - help="Port on vSphere host to connect on (Default: {}).".format( + help=_("Port on VSphere host to connect on (Default: {}).").format( CrTplConfiguration.default_vsphere_port) ) vmware_group.add_argument( - '-U', '--user', dest='user', - help="User name to use when connecting to vSphere host (Default: {!r}).".format( + '-U', '--user', dest='user', metavar=_("USER"), + help=_("User name to use when connecting to VSphere host (Default: {!r}).").format( CrTplConfiguration.default_vsphere_user) ) vmware_group.add_argument( - '-P', '--password', dest='password', - help="Password to use when connecting to vSphere host.", + '-P', '--password', dest='password', metavar=_("PASSWORD"), + help=_("Password to use when connecting to VSphere host."), ) vmware_group.add_argument( - '-F', '--folder', dest='folder', - help="Folder in vSphere, where to create the template (Default: {!r}).".format( + '-F', '--folder', dest='folder', metavar=_("FOLDER"), + help=_("VM folder in VSphere, where to create the template (Default: {!r}).").format( CrTplConfiguration.default_folder) ) vmware_group.add_argument( '-C', '--cluster', dest='cluster', - help="Host cluster in vSphere, where to create the template (Default: {!r}).".format( + help=_( + "Host cluster in VSphere, where to create the template (Default: {!r}).").format( CrTplConfiguration.default_vsphere_cluster) ) vmware_group.add_argument( '-M', '--vm', dest='vm', - help=( + help=_( "The temporary VM, which will be created and converted into a " "template (Default: {!r}).").format(CrTplConfiguration.default_template_vm) ) vmware_group.add_argument( - '-T', '--template', - help=( + '-T', '--template', metavar=_("TEMPLATE"), + help=_( "The name of the created template as result of this script " "(Default: {!r}).").format(CrTplConfiguration.default_template_name) ) @@ -274,7 +293,7 @@ class CrTplApplication(BaseApplication): vmware_group.add_argument( '-N', '--number', '--number-templates', dest='number', type=int, metavar='INT', action=NrTemplatesOptionAction, max_val=CrTplConfiguration.limit_max_nr_templates_stay, - help=( + help=_( "Maximum number of templates to stay in templates folder (" "1 <= x < {max_nr}, Default: {def_nr}).".format( max_nr=CrTplConfiguration.limit_max_nr_templates_stay, @@ -283,7 +302,7 @@ class CrTplApplication(BaseApplication): vmware_group.add_argument( '-R', '--rotate', '--rotate-only', dest="rotate", action='store_true', - help="Execute rortation of existing templates only, don't create a new one." + help=_("Execute rotation of existing templates only, don't create a new one.") ) # ------------------------------------------------------------------------- @@ -328,14 +347,14 @@ class CrTplApplication(BaseApplication): """ - LOG.info("Starting {a!r}, version {v!r} ...".format( + LOG.info(_("Starting {a!r}, version {v!r} ...").format( a=self.appname, v=self.version)) try: ret = self.handler() self.exit(ret) except ExpectedHandlerError as e: - self.handle_error(str(e), "Temporary VM") + self.handle_error(str(e), _("Temporary VM")) self.exit(5) diff --git a/locale/create_vm_template.pot b/locale/create_vm_template.pot index 373c9e7..3466373 100644 --- a/locale/create_vm_template.pot +++ b/locale/create_vm_template.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: create_vm_template 1.0.0\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-02-08 09:56+0100\n" +"POT-Creation-Date: 2019-02-08 10:33+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,6 +17,116 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.6.0\n" +#: lib/cr_vmware_tpl/app.py:67 +msgid "Value must be at least 1, {} was given." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:71 +msgid "Value must be at most {m} - {v} was given." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:96 +msgid "File {!r} does not exists." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:99 +msgid "File {!r} is not a regular file." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:120 +msgid "" +"Creates in the given VSphere environment and cluster a template object, which can be used to " +"spawn different virtual machines." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:196 +msgid "Read configuration:" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:201 +msgid "Enter password for host {h!r} and user {u!r}:" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:231 +msgid "Abort creation of VMWare template after successsful creation of template VM." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:236 +msgid "FILE" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:238 +msgid "Configuration file (default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:241 +msgid "VMWare options" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:245 +msgid "Remote VSphere host to connect to (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:251 +msgid "Port on VSphere host to connect on (Default: {})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:256 +msgid "USER" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:257 +msgid "User name to use when connecting to VSphere host (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:262 +msgid "PASSWORD" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:263 +msgid "Password to use when connecting to VSphere host." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:267 +msgid "FOLDER" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:268 +msgid "VM folder in VSphere, where to create the template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:274 +msgid "Host cluster in VSphere, where to create the template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:281 +msgid "The temporary VM, which will be created and converted into a template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:287 +msgid "TEMPLATE" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:288 +msgid "The name of the created template as result of this script (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:298 +msgid "Maximum number of templates to stay in templates folder (1 <= x < {max_nr}, Default: {def_nr})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:305 +msgid "Execute rotation of existing templates only, don't create a new one." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:350 +msgid "Starting {a!r}, version {v!r} ..." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:357 +msgid "Temporary VM" +msgstr "" + #: lib/cr_vmware_tpl/xlate.py:54 msgid "Module directory: {!r}" msgstr "" diff --git a/locale/de_DE/LC_MESSAGES/create_vm_template.po b/locale/de_DE/LC_MESSAGES/create_vm_template.po index 2acfd9e..72d143f 100644 --- a/locale/de_DE/LC_MESSAGES/create_vm_template.po +++ b/locale/de_DE/LC_MESSAGES/create_vm_template.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: create_vm_template 1.0.0\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-02-08 09:56+0100\n" -"PO-Revision-Date: 2019-02-08 09:56+0100\n" +"POT-Creation-Date: 2019-02-08 10:33+0100\n" +"PO-Revision-Date: 2019-02-08 10:15+0100\n" "Last-Translator: Frank Brehm \n" "Language: de_DE\n" "Language-Team: de_DE \n" @@ -18,6 +18,122 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.6.0\n" +#: lib/cr_vmware_tpl/app.py:67 +msgid "Value must be at least 1, {} was given." +msgstr "Der Wert muss mindesten 1 sein, {} wurde gegeben." + +#: lib/cr_vmware_tpl/app.py:71 +msgid "Value must be at most {m} - {v} was given." +msgstr "Der Wert darf höchsten {m} sein - {} wurde gegeben." + +#: lib/cr_vmware_tpl/app.py:96 +msgid "File {!r} does not exists." +msgstr "Die Datei {!r} existiert nicht." + +#: lib/cr_vmware_tpl/app.py:99 +msgid "File {!r} is not a regular file." +msgstr "Die Datei {!r} ist keine reguläre Datei." + +#: lib/cr_vmware_tpl/app.py:120 +msgid "" +"Creates in the given VSphere environment and cluster a template object, which can be used to " +"spawn different virtual machines." +msgstr "" +"Erstellt in der gegebenen VSphere-Umgebung und -Cluster ein Vorlagen-Objekt, das genutzt werden " +"kann, daraus verschiede virtuelle Maschinen zu erzeugen." + +#: lib/cr_vmware_tpl/app.py:196 +msgid "Read configuration:" +msgstr "Gelesene Konfiguration:" + +#: lib/cr_vmware_tpl/app.py:201 +msgid "Enter password for host {h!r} and user {u!r}:" +msgstr "Eingabe des Passwortes für Host {h!r} und Nutzer {u!r}:" + +#: lib/cr_vmware_tpl/app.py:231 +msgid "Abort creation of VMWare template after successsful creation of template VM." +msgstr "Abbruch der der Erstellung der VMWare-Vorlage nach erfolgreicher Erstellung der Vorlagen-VM." + +#: lib/cr_vmware_tpl/app.py:236 +msgid "FILE" +msgstr "DATEI" + +#: lib/cr_vmware_tpl/app.py:238 +msgid "Configuration file (default: {!r})." +msgstr "Konfigurations-Datei (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:241 +msgid "VMWare options" +msgstr "VMWare-Optionen" + +#: lib/cr_vmware_tpl/app.py:245 +msgid "Remote VSphere host to connect to (Default: {!r})." +msgstr "Der VSphere-Host, mit dem sich verbunden werden soll (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:251 +msgid "Port on VSphere host to connect on (Default: {})." +msgstr "Der Port am VSphere-Host, mit dem sich verbunden werden soll (Vorgabe: {})." + +#: lib/cr_vmware_tpl/app.py:256 +msgid "USER" +msgstr "BENUTZER" + +#: lib/cr_vmware_tpl/app.py:257 +msgid "User name to use when connecting to VSphere host (Default: {!r})." +msgstr "Der Benutzername, um sich mit dem vSphere-Host zu verbinden (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:262 +msgid "PASSWORD" +msgstr "PASSWORT" + +#: lib/cr_vmware_tpl/app.py:263 +msgid "Password to use when connecting to VSphere host." +msgstr "Das Passwort, um sich mit dem VSphere-Host zu verbinden." + +#: lib/cr_vmware_tpl/app.py:267 +msgid "FOLDER" +msgstr "ORDNER" + +#: lib/cr_vmware_tpl/app.py:268 +msgid "VM folder in VSphere, where to create the template (Default: {!r})." +msgstr "Der VM-Ordner in VSphere, in dem die Vorlage erstellt werden soll (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:274 +msgid "Host cluster in VSphere, where to create the template (Default: {!r})." +msgstr "Der Host-Cluster in VSphere, in dem die Vorlage erstellt werden soll (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:281 +msgid "The temporary VM, which will be created and converted into a template (Default: {!r})." +msgstr "" +"Die temporäre Virtuelle Maschine, die erstellt und in eine Vorlage konvertiert wird (Vorgabe: " +"{!r})." + +#: lib/cr_vmware_tpl/app.py:287 +msgid "TEMPLATE" +msgstr "VORLAGE" + +#: lib/cr_vmware_tpl/app.py:288 +msgid "The name of the created template as result of this script (Default: {!r})." +msgstr "Der Name der erstellten Vorlage als Ergebnis dieses Scripts (Vorgabe: {!r})." + +#: lib/cr_vmware_tpl/app.py:298 +msgid "Maximum number of templates to stay in templates folder (1 <= x < {max_nr}, Default: {def_nr})." +msgstr "" +"Die maximale Anzahl von Vorlagen zum Verbleib im Vorlagen-Ordner (1 <= x < {max_nr}, Vorgabe: " +"{def_nr})." + +#: lib/cr_vmware_tpl/app.py:305 +msgid "Execute rotation of existing templates only, don't create a new one." +msgstr "Führe nur Rotation der existierenden Vorlagen aus, erstelle keine neue Vorlage." + +#: lib/cr_vmware_tpl/app.py:350 +msgid "Starting {a!r}, version {v!r} ..." +msgstr "Starte {a!r}, Version {v!r} …" + +#: lib/cr_vmware_tpl/app.py:357 +msgid "Temporary VM" +msgstr "Temporäre VM" + #: lib/cr_vmware_tpl/xlate.py:54 msgid "Module directory: {!r}" msgstr "Modul-Verzeichnis: {!r}" diff --git a/locale/en_US/LC_MESSAGES/create_vm_template.po b/locale/en_US/LC_MESSAGES/create_vm_template.po index 0a2ddee..a5b4384 100644 --- a/locale/en_US/LC_MESSAGES/create_vm_template.po +++ b/locale/en_US/LC_MESSAGES/create_vm_template.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: create_vm_template 1.0.0\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-02-08 09:56+0100\n" +"POT-Creation-Date: 2019-02-08 10:33+0100\n" "PO-Revision-Date: 2019-02-08 09:56+0100\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" @@ -18,6 +18,116 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.6.0\n" +#: lib/cr_vmware_tpl/app.py:67 +msgid "Value must be at least 1, {} was given." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:71 +msgid "Value must be at most {m} - {v} was given." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:96 +msgid "File {!r} does not exists." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:99 +msgid "File {!r} is not a regular file." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:120 +msgid "" +"Creates in the given VSphere environment and cluster a template object, which can be used to " +"spawn different virtual machines." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:196 +msgid "Read configuration:" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:201 +msgid "Enter password for host {h!r} and user {u!r}:" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:231 +msgid "Abort creation of VMWare template after successsful creation of template VM." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:236 +msgid "FILE" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:238 +msgid "Configuration file (default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:241 +msgid "VMWare options" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:245 +msgid "Remote VSphere host to connect to (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:251 +msgid "Port on VSphere host to connect on (Default: {})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:256 +msgid "USER" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:257 +msgid "User name to use when connecting to VSphere host (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:262 +msgid "PASSWORD" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:263 +msgid "Password to use when connecting to VSphere host." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:267 +msgid "FOLDER" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:268 +msgid "VM folder in VSphere, where to create the template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:274 +msgid "Host cluster in VSphere, where to create the template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:281 +msgid "The temporary VM, which will be created and converted into a template (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:287 +msgid "TEMPLATE" +msgstr "" + +#: lib/cr_vmware_tpl/app.py:288 +msgid "The name of the created template as result of this script (Default: {!r})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:298 +msgid "Maximum number of templates to stay in templates folder (1 <= x < {max_nr}, Default: {def_nr})." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:305 +msgid "Execute rotation of existing templates only, don't create a new one." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:350 +msgid "Starting {a!r}, version {v!r} ..." +msgstr "" + +#: lib/cr_vmware_tpl/app.py:357 +msgid "Temporary VM" +msgstr "" + #: lib/cr_vmware_tpl/xlate.py:54 msgid "Module directory: {!r}" msgstr "" @@ -38,3 +148,30 @@ msgstr "" msgid "Found .mo-file: {!r}" msgstr "" +#~ msgid "" +#~ "Creates in the given vSphere environment and " +#~ "cluster a template object, which can be used " +#~ "to spawn different virtual machines." +#~ msgstr "" + +#~ msgid "Configuration file (default: {!r})" +#~ msgstr "" + +#~ msgid "Remote vSphere host to connect to (Default: {!r})." +#~ msgstr "" + +#~ msgid "Port on vSphere host to connect on (Default: {})." +#~ msgstr "" + +#~ msgid "User name to use when connecting to vSphere host (Default: {!r})." +#~ msgstr "" + +#~ msgid "Password to use when connecting to vSphere host." +#~ msgstr "" + +#~ msgid "VM folder in vSphere, where to create the template (Default: {!r})." +#~ msgstr "" + +#~ msgid "Host cluster in vSphere, where to create the template (Default: {!r})." +#~ msgstr "" +