6

Possible Duplicate:
Return the language of a given string

The task is to sort the list of strings. With priority to a specific language. Strings can be written in different languages. Such as Chinese, English, Russian. And I need to first take all the Chinese, and then the rest.

To do this, I want to know what country (language) belongs to a particular character in a string. ( For example on the first letter of)

Are there any classes or methods?

4

2 に答える 2

5
于 2013-01-25T17:16:42.160 に答える
1

このリンクを試してください

文字列の言語を検出する方法は?

コードは(コピー済み)

var text = "¿Dónde está el baño?";
google.language.detect(text, function(result) {
if (!result.error) {
var language = 'unknown';
for (l in google.language.Languages) {
  if (google.language.Languages[l] == result.language) {
    language = l;
    break;
  }
}
var container = document.getElementById("detection");
container.innerHTML = text + " is: " + language + "";
}
});
于 2013-01-25T17:10:26.420 に答える