How can I translate an HTML file?

a 夏天 提交于 2019-12-11 15:21:24

问题


I want to add a translation for an HTML file which contains i.name. I do have an object called energydensity which contains the data I need for translation. This actually is a drop-down list and I want to convert that to Chinese.

I have tried this but this is displaying energy.energydensity in the drop-down list.

<option value="All">{{allLoads}}</option>
      <option *ngFor="let i of ddlLoadType ;">{{'Energy.EnergyDensity.i.Name'}}</option>
    </select>

<option value="All">{{allLoads}}</option>
      <option *ngFor="let i of ddlLoadType ;">{{i.Name}}</option>
    </select>

EN-US json data :
"EnergyDensity": {
    "Heating": "Heating",
                "Cooling": "Cooling",
                "hvac": "HVAC",
                "htg": "Heating",
                "light": "Lighting",
                "plgld": "Plug Load"
    }

I want the whole drop-down list to be converted to Chinese.


回答1:


You might add something like:

<script type="text/javascript">

function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'},'google_translate_element');
}
</script>

This adds a Google Translate Button which translates your page to whatever language the user selects. There is a full example on w3schools.



来源:https://stackoverflow.com/questions/57159147/how-can-i-translate-an-html-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!