Check out this snippet of 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'>`;
Additions include:
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'>▼</span>" +
"<div id='directions_stops_list'>";
In the djangojs.po file, only these translations exist:
#: .\static\javascript\modals.js:49
msgid " Arrives to: "
msgstr " 到达:"
#: .\static\javascript\modals.js:54
msgid " Stops: "
msgstr "站点:"
Why can't Django read translations for: gettex(" Start from: "),gettext(" Line ID: "), and gettext(" Departs at: ")?
Note: Any content between var text =
and
`<div id='arrival_${stop_id}'></div>`+
cannot be translated by Django's gettext.