Translating Login/Registration Page


I am new to tutor, and was trying to work on translation

I put in my custom translations for login and registration page through this command

nano "$(tutor config printroot)/env/build/openedx/locale/vi/LC_MESSAGES/djangojs.po"

And post this I build the image but that leads to an error as following :

Traceback (most recent call last):
  File "./", line 123, in <module>
    execute_from_command_line([sys.argv[0]] + django_args)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/", line 381, in execute_from_command_line
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/", line 375, in execute
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/management/", line 364, in execute
    output = self.handle(*args, **options)
  File "/openedx/venv/lib/python3.8/site-packages/statici18n/management/commands/", line 150, in handle
  File "/openedx/venv/lib/python3.8/site-packages/statici18n/management/commands/", line 114, in _create_output
    data = self._create_javascript_catalog(locale, domain, packages)
  File "/openedx/venv/lib/python3.8/site-packages/statici18n/management/commands/", line 93, in _create_javascript_catalog
    response = catalog.get(self, None, domain=domain, packages=packages)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/", line 201, in get
    self.translation = DjangoTranslation(locale, domain=domain, localedirs=paths)
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/translation/", line 156, in __init__
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/translation/", line 208, in _add_local_translations
    translation = self._new_gnu_trans(localedir)
  File "/openedx/venv/lib/python3.8/site-packages/django/utils/translation/", line 176, in _new_gnu_trans
    return gettext_module.translation(
  File "/opt/pyenv/versions/3.8.6/lib/python3.8/", line 598, in translation
    t = _translations.setdefault(key, class_(fp))
  File "/opt/pyenv/versions/3.8.6/lib/python3.8/", line 261, in __init__
  File "/opt/pyenv/versions/3.8.6/lib/python3.8/", line 456, in _parse
    catalog[str(msg, charset)] = str(tmsg, charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 1: ordinal not in range(128)

Now, from what I understand is that probably this file is being copied or it’s content are being copied to edx’s conf/locale

So I translated the files in my local (non tutor, normal edx devstack) and it works there.
I pushed .mo files into repo and tried to build the repo from there using following command

tutor images build openedx --build-arg EDX_PLATFORM_REPOSITORY=MY-REPO --build-arg EDX_PLATFORM_VERSION=MY-BRANCH

And that followed by

tutor local stop
tutor local start -d
tutor local restart

That gave me no results, if I change the content of the file that gets reflected, however the translation does not.

Those translations are not easy and direct to put up they require more than normal steps (shown in the post here)

And I try to run those commands

for example

tutor dev run lms paver i18n_fastgenerate

and have also tried to build the assets through tutor command

tutor local run lms openedx-assets build

but that also fetches no result.

Open edx version: koa
Tag: open-release/koa.2
Tutor version : tutor, version 11.2.2
Operating system: 20.04

Line 456 in the module (where the error stacktrace you posted comes from) is preceded by the following comment:

        # Note: we unconditionally convert both msgids and msgstrs to
        # Unicode using the character encoding specified in the charset
        # parameter of the Content-Type header.  The gettext documentation
        # strongly encourages msgids to be us-ascii, but some applications
        # require alternative encodings (e.g. Zope's ZCML and ZPT).  For
        # traditional gettext applications, the msgid conversion will
        # cause no problems since us-ascii should always be a subset of
        # the charset encoding.  We may want to fall back to 8-bit msgids
        # if the Unicode conversion fails.

It looks like you created msgids with non-ascii values. Can you share the djangojs.po file you created?

Hey @regis Although I’ve now shifted to native install, I’d still like to know the cause.

Same lines work in native.

Here is one such line example

#: lms/templates/student_account/login.underscore
msgid “Create an Account.”
msgstr “Tạo tài khoản”

I was aware about the non ascii or unicode issues but if that was the case, native should have thrown the error as well. And thus I thought I might have configured something wrong or was doing something wrong from my side on tutor.

After investigation, you need to specify the content type in your po file. I replicated your error with the following djangojs.po file:

#: lms/templates/student_account/login.underscore
msgid "Create an Account."
msgstr "Tạo tài khoản"

But this one compiled successfully:

msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8"

#: lms/templates/student_account/login.underscore
msgid "Create an Account."
msgstr "Tạo tài khoản"

I guess we should add that to the docs.

Great catch man, thanks @regis

Open edX makes us learn something new everyday.

You got that right! :joy: And sometimes I wish I did not have to learn all of this stuff…

1 Like