简体   繁体   English

django:javascript 翻译的一部分不起作用

[英]django: part of javascript translation doesnot work

here is my code:这是我的代码:

 var text = `<div id='weather_data'>
            <img id='weather_icon' src='${weather_icon}'>
            <span id='centered'>${data[0].temperature}°c</span>
            </div>
            <h2>Steps:</h2>
            <ul id='journey_info'>`;

and

 text +=
                "<li>" +
                gettext(" Start from: ") +
                "<br>" +
                data[i].start_name +
                "<br>" +
                "<br>" +
                gettext(" Line ID: ") +
                line_id +
                "<br>" +
                "<br>" +
                gettext(" Departs at: ") +
                getTime(data, i) +
                `<div id='arrival_${stop_id}'></div>` +
                "<br>" +
                gettext(" Arrives to: ") +
                "<br>" +
                data[i].end_name +
                "<br>" +
                "<br>" +
                gettext(" Stops: ") +
                data[i].num_stops +
                " • " +
                data[i].travel_time +
                "mins <span id='arrow'>&#9660</span>" +
                "<div id='directions_stops_list'>";

in my djangojs.po file, there are only:在我的djangojs.po文件中,只有:

#: .\static\javascript\modals.js:49
msgid " Arrives to: "
msgstr " 到达:"

#: .\static\javascript\modals.js:54
msgid " Stops: "
msgstr "站点:"

so part of gettext are found by django.所以 gettext 的一部分被 django 找到。 but Why can't it read: gettext(" Start from: "),gettext(" Line ID: ") and gettext(" Departs at: ")?但是为什么不能读:gettext("Start from:"),gettext("Line ID:") and gettext("Departs at:")?

Notice: any code between var text = and `<div id='arrival_${stop_id}'></div>` + couldnot be recognized by gettext .注意: var text =`<div id='arrival_${stop_id}'></div>` +之间的任何代码都无法被gettext识别。

Sorry but it all works for me:对不起,但这一切都对我有用:

#: templates/modal.js:9
msgid " Start from: "
msgstr ""

#: templates/modal.js:14
msgid " Line ID: "
msgstr ""

#: templates/modal.js:18
msgid " Departs at: "
msgstr ""

#: templates/modal.js:22
msgid " Arrives to: "
msgstr ""

#: templates/modal.js:27
msgid " Stops: "
msgstr ""

But since we're missing ~27 lines, you should simply delete one statement at a time from the top, till it starts working.但是由于我们遗漏了大约 27 行,您应该从顶部一次删除一条语句,直到它开始工作。 There's something that Django trips over and until you identify it, there's not much we can do to help. Django 有一些东西会绊倒,在您发现它之前,我们无能为力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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