How can I convert language of a div?

后端 未结 4 1214
南旧
南旧 2020-12-22 10:15

I am recently working in a project. There I need to convert language from English to Japanese by button click event. The text is in a div. Like this:

\"

        
4条回答
  •  眼角桃花
    2020-12-22 11:01

    If you mean translating the text, you cannot do it easily. To get some idea of the best attempts that software can make at translating natural languages, go to Google Translate or Babelfish. It's not that good, but it's sometimes an intelligible starting point.

    If you just mean setting the language attribute on an element, then assign a new language code to the lang property of the div element object.

    document.getElementById("normaltext").lang = "en-US";
    

    I don't know the language code for Japanese; possibly ja-ja.

提交回复
热议问题