Error in translation: Some parts of JavaScript code are not functioning properly in Django

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'>&#9660</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.

Answer №1

Unfortunately, everything seems to be functioning correctly on my end:

#: templates/modal.js:9
msgid " Begin at: "
msgstr ""

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

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

#: templates/modal.js:22
msgid " Reaches at: "
msgstr ""

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

However, there appears to be an issue with approximately 27 lines missing. The recommended solution is to systematically remove one statement at a time from the beginning until functionality is restored. Django may be encountering a problem that needs to be addressed before further assistance can be provided.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to iterate through an array and make use of index values while removing any empty elements along the

In my current setup, I have defined two arrays keyVals and rows: keyVals = [ "Status", "ErrorHeading", "ErrorDetail" ] rows = [ { "Hostname": "ABC", "name& ...

Using a three.js texture with a JSON object

Currently, I am working on a customization project where I am using three.js to export an HTML5 canvas as a 3D preview. My goal is to have the texture placed only on the front side, but it seems to appear on all sides instead. This is the code I am using: ...

Is there a way to have an iframe resize its height based on its content without needing a scrollbar?

For instance: <iframe name="Unique" src="http://uniqueness.com/" width="780m" frameborder="0" scrolling="no" id="unique-iframe"> ... </iframe> I desire the iframe to dynamically adjust its height based on the content it contains, elim ...

Discover records that include the specific object id within an array (Mongodb)

I'm currently tackling a node project and struggling with using the find() function on an array of object ids. Let me share an example of a document stored in my mongodb database: { "_id": { "$oid": "6515923586714e6ae70 ...

Tips for updating the contents of a div dynamically in JavaScript/jQuery without the need for clicking a button or a link

Is there a way to automatically reload or refresh the content of a specific div element without refreshing the entire page, and without any user interaction such as clicking a button or link? I am looking to update the div with the id 'div_graph' ...

To ensure maximum efficiency, it is crucial to iterate through each individual td element within a tr loop when extracting data from

I have successfully developed a code in JavaScript and AJAX to convert JSON data into an HTML table. The structure of the data is such that column 1 represents text, column 2 contains a link, and column 4 consists of links for images. Data: [ ["Produ ...

Consider replacing the custom attribute directive in Angular with a different directive

I am currently working on a custom attribute directive to handle a src-like attribute that represents a relative path to a directory. The directory path is stored in a global variable (let's call it mydir). This attribute should be replaced with an ...

Showing an image in a Django template using get_absolute_url

I am attempting to showcase an image in my template using the get_absolute_url model method. Model: class UserData(models.Model): ...... photo = models.ImageField(upload_to='photo/', blank=True) def __unicode__(s ...

The process of incorporating content from a different page into a Bootstrap 5 Modal can be achieved by using Laravel 10

Here is a snippet of my code from index.blade.php: <a data-bs-toggle="modal" data-bs-target="#modal_frame" href="{{route('caborCreate')}}">link</a> This is how the modal is coded in the create page - cre ...

Can we safely save a value in session storage directly from the main.js file in Vue?

Throughout the user session managed by Vuex, I have a session storage value set to false that needs to be monitored. Setting up this value directly from the main.js file looks like this: import { createApp } from 'vue'; import App from './Ap ...

@HostBinding in Angular 2 does not trigger change detection

When using @HostBinding in conjunction with Chrome's Drag and Drop API, the code looks like this: @Directive({ selector: '[sortable-article]' }) export class SortableArticleComponent { @HostBinding('class.dragged-element') ...

Utilizing Core-TransitionEnd in Polymer: A Beginner's Guide

After a ripple animation on an item has executed, I would like to run a function. Currently, I am using the following code: <post-card id="card1"> <img width="70" height="70" src="../images/start.png"> <h2>P ...

After the element has been inserted, dom.byId will give you an undefined response

I have encountered an issue with a function that adds a div as a child to a dijit/layout/contentpane. The problem arises when I attempt to reference this div using dom.byId after adding it to the content pane. The function is triggered by a click event on ...

Experiencing discrepancies in pixel height while conducting tests using Nightwatch

Let me start by sharing some details about my machine setup: Operating System: CentOS 7 Graphics Drivers: kmod-nvidia (dedicated GPU) I am currently testing a webpage using Nightwatch, and one of the requirements is to ensure that a background image&apo ...

Display message in a modal using React or JavaScript

Here's a puzzling query I have: Users can upload .MSG files to our system, and the BASE64 data is stored in the database. Now, I'm trying to incorporate these .MSG files into a model but facing conversion issues with BASE64 data. Interestingly, I ...

Arrange the grid in a pleasing manner

I'm really struggling with this issue. In my current setup, I have a Grid container that holds two separate grids - one for a textfield and another for a checkbox. Unfortunately, I can't seem to get them to align properly. <Grid container& ...

Safari browser is experiencing issues with the custom file upload script

My custom upload script allows users to easily select images for upload by clicking or dragging them into the designated box. A preview of the chosen image should appear, and this functionality works smoothly in Firefox and Chrome. However, I've encou ...

D3 group of legendary elements

Is there a way to group both the circle and text elements for each legend item together? I'm currently facing a challenge with the enter/exit methods. While I can create the groups (g), I'm unable to append the text and circle elements. li.sel ...

Transmit data to PHP via Ajax without needing to redirect

Struggling to figure out how to send an image from ajax to PHP after uploading it in a form? Here is the ajax call you can take a look at: var dataString = 'city='+ city_push + '&venue=' + venue_push + '&title=' + ti ...

When I execute a raw query in Django, it retrieves duplicate user entries for each

Having an issue with fetching data from my database using a raw query in my view: SELECT stressz_profile.id, projekt_id, user_name_id, szerv01b AS szervkult01a FROM stressz_szervezetikultura INNER JOIN stressz_profile WHERE stressz_profile.projekt_id=1 ...