简体   繁体   English

如何使用 JQuery/Javascript 翻译表格中的文本?

[英]How do i translate text in a table Using JQuery/Javascript?

Below is the code i wish to translate to French下面是我希望翻译成法语的代码

<table border="1">
        <tr>           
            <th>Description (French)</th>          
        </tr>

        <tr>           
            <td><p id="desc_F_T"></p></td>
        </tr>
</table>

The text for that table data is retrieved from a weather API with the following code:该表数据的文本是从天气 API 中检索到的,代码如下:

$(document).ready(function() {
  $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=Toronto,CA&appid=[apiKey]', function(data) {
    console.log(data);
    $("#desc_F_T").html(data.weather[0].description)
  });
});

I want to now translate that text to French, how do I do that using Jquery/Javascript?我现在想将该文本翻译成法语,我该如何使用 Jquery/Javascript 来做到这一点? Note: I do not want to translate the entire page, just that single table data.注意:我不想翻译整个页面,只是那个单表数据。

Just add &lang=fr to your request as seen in the documentation只需将&lang=fr添加到您的请求中,如文档中所示

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

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