Changing translations has no effect

Hi. I’m running openedx quince.1 on local and palm.4 in production. We need to change the course end date description translations. I changed the translations from tutor/env/build/openedx/locale/<my-locale>/LC_MESSAGES/django.po and then rebuilt the openedx image using tutor images build openedx and re-launched but nothing changed.

I even tried running python manage.py lms compilemessages in the lms container but the translations are still the same as the original. This problem exists in both palm and quince. This is the section I’m talking about:

image

I also tried copying the django.po file to the container and running python manage.py compilemessages from inside container but still no change.

What is the content of your django.po file?

A bunch of standard msgstr and msgid. For example this specific line looks like this:

#: lms/djangoapps/courseware/date_summary.py
msgid ""
"After the course ends, the course content will be archived and no longer "
"active."
msgstr ""
"Replace this string!!"

Same problem exists with this one:

#. #-#-#-#-#  django-partial.po (edx-platform)  #-#-#-#-#
#. Translators: 'Discussion' refers to the tab in the courseware that leads to
#. the discussion forums
#: cms/djangoapps/contentstore/views/component.py
#: lms/djangoapps/courseware/tabs.py lms/djangoapps/discussion/plugins.py
#: openedx/core/djangoapps/discussions/plugins.py
#: openedx/features/lti_course_tab/tab.py xmodule/discussion_block.py
#: lms/djangoapps/discussion/templates/discussion/discussion_profile_page.html
#: lms/templates/ux/reference/bootstrap/course-skeleton.html
msgid "Discussion"
msgstr "Replace this!!"

The translation strings that you are trying to replace do not actually appear in edx-platform, but in the learning microfrontend (MFE). Notice that they are present in “http(s)://apps.yourlms.com” pages. The “apps” prefix indicates an MFE. You should customize these strings using a different approach: GitHub - overhangio/tutor-mfe: This plugin makes it possible to easily add micro frontend (MFE) applications on top of an Open edX platform that runs with Tutor.

Thanks for the response but I don’t agree with you. The content for the tabs in learning MFE is returned from server I believe. Look at this API call please.

https://mylms.com/api/course_home/course_metadata/course-id

It’s a get request sent from learning MFE to LMS when the page is loading. The response to this request looks like this:

{
    "can_show_upgrade_sock": false,
    "verified_mode": null,
    "celebrations": {
        "first_section": false,
        "streak_length_to_celebrate": null,
        "streak_discount_enabled": false,
        "weekly_goal": false
    },
    "course_access": {
        "has_access": true,
        "error_code": null,
        "developer_message": null,
        "user_message": null,
        "additional_context_user_message": null,
        "user_fragment": null
    },
    "course_id": "course-id",
    "is_enrolled": true,
    "is_self_paced": false,
    "is_staff": true,
    "number": "course-id",
    "org": "myorg",
    "original_user_is_staff": true,
    "start": "2023-10-07T12:30:00+03:30",
    "tabs": [
        {
            "tab_id": "courseware",
            "title": "دوره آموزشی",
            "url": "https://apps.mylms.com/learning/course/course-id/home"
        },
        {
            "tab_id": "progress",
            "title": "پیشرفت",
            "url": "https://apps.mylms.com/learning/course/course-id/progress"
        },
        {
            "tab_id": "dates",
            "title": "تاریخ‌ها",
            "url": "https://apps.mylms.com/learning/course/course-id/dates"
        },
        {
            "tab_id": "discussion",
            "title": "گفتگو",
            "url": "https://apps.mylms.com/discussions/course-id/"
        },
        {
            "tab_id": "instructor",
            "title": "مربی",
            "url": "https://mylms.com/courses/course-id/instructor"
        }
    ],
    "title": "my course",
    "username": "admin",
    "user_timezone": null,
    "can_view_certificate": true
}

So I guess the tabs, their name and their url is generated from this response. So the translations are coming from LMS in my opinion.

You are absolutely right, and I was wrong. On my local platform, the translated string comes from the following url: http://local.edly.io/api/course_home/outline/course-v1:edX+DemoX+Demo_Course

So overriding the translations in a django.po file should work. Indeed, I am able to override the “After the course ends” string by creating a ~/.local/share/tutor/env/build/openedx/locale/fr/LC_MESSAGES/django.po file with the following content:

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

msgid ""
"After the course ends, the course content will be archived and no longer "
"active."
msgstr ""
"POUAC!"

As per the docs.


(notice the “POUAC!” string in the right column)

If the same approach does not work for you, it might be because your django.po file is incorrectly formatted. You might glean more information by running:

tutor local run --no-deps lms bash
cd ../locale/user
django-admin compilemessages -v1 -l yourlocale

Good to hear it’s working for you, but it’s still not working for me : (

I ran the django-admin compilemessages -v1 -l fa_IR from within the container as you said. The files compiled fine with no errors but my translations are still the same. This is getting really frustrating.

What’s the current user configured language? (from the “account” page) Mine is configured as “Français” (French).

It’s set to Persian (Iran). Language code is set to fa-ir in https://mylms.com/update_lang/ as well.

I deleted the translation file. Created it again, pasted the content from the original file and now, finally it’s working!
I still don’t know what was wrong with the original file. Cause it gave no errors during build / compilemessages and compiled successfully. As I said in the first post, I even copied the file into the container and ran compilemessages and it still wasn’t working. Now I just deleted it, and added the exact same content, copy paste literally, and finally it’s ok!

The even more strange part is that, this issue didn’t happen with all changes in the original file. Just some of the words had this issue and other translation changes were working just fine.

You almost certainly had a syntax error in your po file. You can check your syntax with:

msgfmt --check ~/.local/share/tutor/env/build/openedx/locale/.../django.po

The funny thing is that this command returns no error for the original file :)))
By the way, I thought that if a translation file has syntax error, the compile process will fail. Won’t it?

I honestly have no idea…

Me too :)) But thanks a lot for your time and help.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.