[openstack-dev] [osc][openstackclient][cliff] translation the command description in help
Steve Martinelli
s.martinelli at gmail.com
Tue Nov 15 21:08:50 UTC 2016
The following is a PSA for all OpenStackClient plugins.
Matt Edmonds filed bug 1636209 [1] against OpenStackClient because the main
help message was not getting translated. In the example below, the "Create
new user" string was not translated (some of the help text was removed for
readability):
====================================
$ openstack user create --help
usage: openstack user create [-h]
... [--password <password >] <name>
Create new user <<<<<
positional arguments:
<name> New user name
optional arguments:
--password < password> Set user password
====================================
As it turns out, this was because we were setting this help message in a
docstring, which could not be marked for translation. cliff was
automatically picking up the docstring and using that (as-designed).
Doug Hellmann fixed the issue for cliff by allowing a class attribute [2],
and I proposed a patch for OpenStackClient [3]. Look for a new cliff
release soon, and a bump to the minimum version in global-requirements.
In case you want to do this in your plugin (assuming you are setup for
translations), and not handcraft 100+ lines, you can run the following
commands (this is what I used, and I'm sure someone will come up with a
better way of doing it)
$ find . -name '*.py' -exec sed -i .bak -e
's/""".*"""/_description=_("&")/g' {} \;
$ find . -type f -name '*.py.bak' -delete
$ git checkout examples/ releasenotes/ openstackclient/tests/
Thanks for reading!
Steve
[1] https://bugs.launchpad.net/python-openstackclient/+bug/1636209
[2] https://review.openstack.org/#/c/397321/
[3] https://review.openstack.org/#/c/396939/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20161115/ee78661a/attachment.html>
More information about the OpenStack-dev
mailing list