简体   繁体   中英

Django javascript-catalog missing data from .po file

I am trying to set up a javascript-catalog translation for my project, but to me it seems it is not reading the .po/.mo files

My url patterns:

urlpatterns = i18n_patterns(
    ....
    path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
    ....
    )

I have this header in my template:

<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>

After checking the source of the rendered template for "Hungarian" language I see a bunch or default translations in the JS catalog file, but not the ones I defined in the .po file:

const newcatalog = {
    "%(sel)s of %(cnt)s selected": [
      "%(sel)s/%(cnt)s kijel\u00f6lve",
      "%(sel)s/%(cnt)s kijel\u00f6lve"
    ],
    "6 a.m.": "Reggel 6 \u00f3ra",
    "6 p.m.": "Este 6 \u00f3ra",
    "April": "\u00e1prilis",
    "August": "augusztus",
    "Available %s": "El\u00e9rhet\u0151 %s",
    "Cancel": "M\u00e9gsem",
    "Choose": "V\u00e1laszt\u00e1s",
    "Choose a Date": "V\u00e1lassza ki a d\u00e1tumot",
    "Choose a Time": "V\u00e1lassza ki az id\u0151t",
    "Choose a time": "V\u00e1lassza ki az id\u0151t",
    "Choose all": "Mindet kijel\u00f6lni",
    "Chosen %s": "%s kiv\u00e1lasztva",
    "Click to choose all %s at once.": "Kattintson az \u00f6sszes %s kiv\u00e1laszt\u00e1s\u00e1hoz.",
    "Click to remove all chosen %s at once.": "Kattintson az \u00f6sszes %s elt\u00e1vol\u00edt\u00e1s\u00e1hoz.",
    "December": "december",
    "February": "febru\u00e1r",
    "Filter": "Sz\u0171r\u0151",
    "Hide": "Elrejt",
    ...

In my .po file I have:

msgid "Routes"
msgstr "Utak"

Which is compiled into a .mo file, however when I call

$(document).ready(function () {
    console.log(gettext('Routes'));
});

It is not translated. If I select a string from the javascript-catalog it is translated correctly, so to me it seems that the javascript-catalog is not connected to my .po/.mo files.

What am I doing wrong?

我能够通过将域从默认的djangojsdjango来解决它

path('jsi18n/', JavaScriptCatalog.as_view(domain="django"), name='javascript-catalog'),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM