Management Commands

Regenerate and compile the web console’s gettext message catalogs.

smarter.apps.dashboard.management.commands.update_console_messages.CONSOLE_MESSAGES_DIR = PosixPath('console/i18n')

Where scripts/fetch_console.py installs messages.js, the web console’s messages, relative to the project root.

Each release of smarter-sh/smarter-console carries it, and make console installs the pinned release’s. makemessages reads only this directory for the djangojs domain.

class smarter.apps.dashboard.management.commands.update_console_messages.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: SmarterCommand

Django manage.py update_console_messages command.

Regenerates smarter/smarter/locale/<language>/LC_MESSAGES/django.po, from the Django templates and Python code, and djangojs.po, from the web console’s messages in console/i18n/messages.js, for each language in settings.LANGUAGES, then compiles them to .mo files. A regional language code is written to its locale name’s directory, e.g. pt-br to locale/pt_BR. Translations already in the .po files are kept.

make console installs the pinned console release’s messages.js first, and make i18n-messages runs this command in the smarter-api container. Without messages.js, it exits with an error that says so.

add_arguments(parser)[source]

Add the --language and --no-compile options.

Parameters:

parser – The command’s argument parser.

handle(*args, **options)[source]

Regenerate django.po and djangojs.po for each language, then compile them unless --no-compile.

Runs makemessages from the project root and from the React messages directory, and restores the working directory afterwards.

Parameters:

options – The command’s options: languages, no_compile and verbosity.

help = "Regenerate the web console's message catalogs, django.po and djangojs.po, in smarter/smarter/locale, for each language in settings.LANGUAGES, and compile them."
smarter.apps.dashboard.management.commands.update_console_messages.DJANGO_IGNORE_PATTERNS = ['console', 'react', 'static', 'staticfiles', 'node_modules', 'requirements', 'venv']

Directories, under the project root, that makemessages skips for the django domain.

The web console’s messages (the djangojs domain), and static and third-party files, which hold no messages of Django’s own.

[
    'console',
    'react',
    'static',
    'staticfiles',
    'node_modules',
    'requirements',
    'venv',
]