How to detect language of text?

前端 未结 5 560
醉梦人生
醉梦人生 2020-12-14 20:50

I have a form which lets users input text snippets. So how can figure out the language of the entered text?

Specifically these languages for now:

Arabic: هذه

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 21:02

    Presumably guessing the user's language is to display responses in the proper language. What about examining the browser's settings for preferred languages? Obtain that from the HTTP header Accept-Language. See section 14.4 here.

提交回复
热议问题