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
This commit is contained in:
Akihiro Motoki 2017-08-29 12:17:26 +00:00
parent c3f6ee141b
commit f3e9ef5851
2 changed files with 25 additions and 11 deletions

View File

@ -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 "

View File

@ -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 "