AZ.
AZ.

Reputation: 7593

How can I know in Javascript if a web page is in English or Non-English?

To be specific, how do you check the web page source to determine whether this web page is shown in English or other language, such as Japanese or French?

Upvotes: 0

Views: 490

Answers (2)

Noon Silk
Noon Silk

Reputation: 55172

It's not possible, really.

I mean, lets consider that a given page can be shown in both English and French at the same time. Perhaps you want to get something like the request-language in JavaScript. I think something like this may be available in the user-agent string, which you can get (infact, perhaps the object has the request-language directly in it somewhere).

Of course, even if you do get this, it doesn't mean the page is in that language.

Given that you are the server, and you know what language you rendered in (hopefully) you can just pass this information to JavaScript via some variable.

Upvotes: 1

Warty
Warty

Reputation: 7405

The following information will NOT always be present, and it will not actually tell you what language is used on the website.
charset, as in <meta http-equiv="Content-Type" content="text/html; charset=blah">
if charset is set to EUC-KR, you know its targeted towards people in korea, and korean characters can be used... [alt codes]

Of course, even if EUC-KR is set as the charset, you can still use the english alphabet, and of course, write english sentences...

Other than that, the only other way for you to detect the language of a website would be... actually looking at individual words and checking to see what dictionary they're in...

Upvotes: 1

Related Questions