From f3e9ef5851d54bd9a5d17c87c4a94e2ff5886464 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Tue, 29 Aug 2017 12:17:26 +0000 Subject: [PATCH] extract_messages, update_catalog: Simplify help message Previously the help message of update_catalog shows all available languages in the command example. It is difficult to understand what an exact command line is expected. This commit uses metavar to simplify the brief command line and shows available languages in the help text. Similar change is made to 'domain' argument of update_catalog and of extract_messages. Also the default values are added in the help message. Change-Id: I63efea7e368eb1dfaf203ca4c515eb57173b571e --- .../management/commands/extract_messages.py | 16 ++++++++++----- .../management/commands/update_catalog.py | 20 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/openstack_dashboard/management/commands/extract_messages.py b/openstack_dashboard/management/commands/extract_messages.py index 567b2962e2..fe28af9026 100644 --- a/openstack_dashboard/management/commands/extract_messages.py +++ b/openstack_dashboard/management/commands/extract_messages.py @@ -18,6 +18,9 @@ from subprocess import call from django.core.management.base import BaseCommand +DOMAINS = ['django', 'djangojs'] +MODULES = ['openstack_dashboard', 'horizon'] + class Command(BaseCommand): help = ('Extract strings that have been marked for translation into .POT ' @@ -25,12 +28,15 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('-m', '--module', type=str, nargs='+', - default=['openstack_dashboard', 'horizon'], + default=MODULES, help=("The target python module(s) to extract " - "strings from")) - parser.add_argument('-d', '--domain', choices=['django', 'djangojs'], - nargs='+', default=['django', 'djangojs'], - help="Domain(s) of the .pot file") + "strings from. " + "Default: %s" % MODULES)) + parser.add_argument('-d', '--domain', choices=DOMAINS, + nargs='+', default=DOMAINS, + metavar='DOMAIN', + help=("Domain(s) of the .pot file. " + "Default: %s" % DOMAINS)) parser.add_argument('--check-only', action='store_true', help=("Checks that extraction works correctly, " "then deletes the .pot file to avoid " diff --git a/openstack_dashboard/management/commands/update_catalog.py b/openstack_dashboard/management/commands/update_catalog.py index 07360da61a..94a11c2b1c 100644 --- a/openstack_dashboard/management/commands/update_catalog.py +++ b/openstack_dashboard/management/commands/update_catalog.py @@ -28,6 +28,8 @@ LANGUAGE_CODES = [language[0] for language in settings.LANGUAGES if language[0] != 'en'] POTFILE = "{module}/locale/{domain}.pot" POFILE = "{module}/locale/{locale}/LC_MESSAGES/{domain}.po" +DOMAINS = ['django', 'djangojs'] +MODULES = ['openstack_dashboard', 'horizon'] def translate(segment): @@ -61,14 +63,20 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('-l', '--language', choices=LANGUAGE_CODES, default=LANGUAGE_CODES, nargs='+', - help=("The language code(s) to pseudo translate")) + metavar='LANG', + help=("The language code(s) to pseudo translate. " + "Available languages are: %s" + % ', '.join(sorted(LANGUAGE_CODES)))) parser.add_argument('-m', '--module', type=str, nargs='+', - default=['openstack_dashboard', 'horizon'], + default=MODULES, help=("The target python module(s) to extract " - "strings from")) - parser.add_argument('-d', '--domain', choices=['django', 'djangojs'], - nargs='+', default=['django', 'djangojs'], - help="Domain(s) of the .POT file") + "strings from. " + "Default: %s" % MODULES)) + parser.add_argument('-d', '--domain', choices=DOMAINS, + nargs='+', default=DOMAINS, + metavar='DOMAIN', + help=("Domain(s) of the .POT file. " + "Default: %s" % DOMAINS)) parser.add_argument('--pseudo', action='store_true', help=("Creates a pseudo translation for the " "specified locale, to check for "