Warm tip: This article is reproduced from serverfault.com, please click

Django Translations only partially working

发布于 2020-11-20 02:02:35

I've done makemessages and compilemessages and both files contain the translation that is inside a {% blocktranslate %}. I've even re-run makemessages to make sure nothing changed in the msgid and it did not make any change to my .po file except for the POT-Creation-Date. But these {% blocktranslate %} paragraphs are not translating. I'm stuck with the msgid instead of the msgstr.

Is there some trick to very long msgid's?

I'm assuming the keys don't match, but not sure why they don't match since the tools don't change the values when re-run.


The problem has gotten worse, now some of the short translations just aren't working either.

Here is the rendered page:

1/4 Translated UI

Here is the source that renders it:

            <li class="nav-item {% is_active_tab 'home' %}">
                <a class="nav-link" href="{% url 'home' %}">
                    {% translate "Home" %}
                </a>
            </li>
            {% if request.user.is_authenticated %}
                <li class="nav-item {% is_active_tab 'games:list' %}">
                    <a class="nav-link" href="{% url 'games:list' %}">
                        {% translate "My Quizzes" %}
                    </a>
                </li>
                <li class="nav-item {% is_active_tab 'games:create' %}">
                    <a class="nav-link" href="{% url 'games:create' %}">
                        {% translate "New Quiz" %}
                    </a>
                </li>

And here is the .po file

#: templates/site_base.html:41
msgid "Home"
msgstr "Inicio"

#: templates/site_base.html:47
msgid "My Quizzes"
msgstr "Mis Cuestionarios"

#: templates/site_base.html:52
#, fuzzy
msgid "New Quiz"
msgstr "Nuevo Cuestionario"

Yes, I have run compilemessages

(bb) $ manage compilemessages
     processing file django.po in .../locale/es_MX/LC_MESSAGES

And based on the first translation it is finding the file, but then it only translates a few of the terms. The Admin translations are better (more complete) but I'm not sure what I'm doing wrong. I thought it might be LOCALE_PATHS so I added this to my settings but then remembered that compilemessages was already finding the file so that had no effect....

LOCALE_PATHS = [
    BASE_DIR / 'locale',
]

Update: I was using the locale of es_MX. When I converted back to just es, it started working, and removing the #fuzzy was the other part of the fix. I'm not sure how you do variations on spanish, but for the moment, I'm just not worrying about that.

Questioner
boatcoder
Viewed
0
François Fournier 2020-12-05 04:24:56

Your code does not show any {% blocktranslate %} so it is hard to provide an appropriate answer.

For the short translation, the #, fuzzy disallow the .po entry to be used and it won't translate.