Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
1732 มุมมอง

Hi. I have a js file in snippet who sends a form via ajax to controller and it response with True/False and message. Per example:

if file_size > MAX_FILE_SIZE:
​​response_data = {
   'status': False,
   'message': f'The file {file.filename} exceeds the maximum size allowed of 1 MB.'
}
return request.make_response(json.dumps(response_data), headers={'Content-Type': 'application/json'})

In the javascript file I get this response and show the message

if (response.status == true) {
    $('.product_rating_container .container').addClass('px-0').html('<div class="alert alert-success mb-0" role="alert">' + _lt(response.message) + '</div>');                       

}

And here y mark with _lt to make this text translatable but now if I download the po file translation file of my module, this text doesn't show to be translated. What should I do?

Thanks.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

To translate text sent from a controller to JavaScript via an XHR (XMLHttpRequest) response, you need to follow these steps:

  1. Set up the server-side controller to generate and send the response.
  2. Create the XHR request in JavaScript to fetch the data from the server.
  3. Handle the response in JavaScript to process and display the translated text.

อวตาร
ละทิ้ง
ผู้เขียน

Sorry but have you read my message? Seems a chatgpt generic answer... I already did all the steps you wrote, as I said in my text

Related Posts ตอบกลับ มุมมอง กิจกรรม
ajax.loadXML in odoo16 แก้ไขแล้ว
1
มิ.ย. 23
3065
4
มี.ค. 25
3906
2
ก.ย. 23
3964
0
พ.ค. 23
1936
2
ก.พ. 23
2339