0

i have a news script

and it multi language ..

i want detect automaticlly the language of the visitor ...

i found more questions here about get the country from javascript timezone

them problem was because more citis is Similar time

" I DONT WANT DETECT COUNTRY " <- if that hard to get it !

only language !

so , what is the best way to get the visitor language or country by javascript ?

i don't understand javascript ever ! , and can't know what you can do by javascript

my two ideas is ..

first idea

get the time of visitor

example

EG = 0300

and in php i make an array contain ('0200'=>'Egypt') and another array ('Egypt'=>'AR')

second idea

in my clock time zone box , i see

Time Zone : Cairo <- egypt

can we get the name ?

Thank you !

Osama Tarek
  • 297
  • 5
  • 16

3 Answers3

3

You do not want to use time zones to determine language. People in the same time zone can speak different languages.

One alternative is to check the accept-language header.

For a similar discussion see: How do you detect a website visitor's country (Specifically, US or not)?

Community
  • 1
  • 1
Henry
  • 222
  • 1
  • 5
  • i don't understand this information based on what ! , but i tried it from 3 computers for my friends ! , result is en-us,en;q=0.5 and they can't speak english ! – Osama Tarek Jul 28 '11 at 12:29
  • 1
    @Osama are they running an English browser/operating system/environment? accept-language is usually set by the browser. – Henry Jul 28 '11 at 12:35
1

You can't get the country or language from the time zone offset.

For example, take UTC+1 in winter time. This could be France, Spain, Norway, Germany, Belgium, etc. They're all in Central European Time.

If you can get an Olsen name such as "Europe/France" or "Europe/Germany" that clearly gives you a lot more information, but you can't get that just from the offset from UTC.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
0

Generally this can work, kinda.

But you would not get an specific location.

Especially in Europe and Africa there can be a lot of countries in one time zone and you couldnt differ between them.

I hope this helps

anmother way to do it ip location: http://www.geobytes.com/iplocator.htm?getlocation

http://jquery-howto.blogspot.com/2009/04/get-geographical-location-geolocation.html

from the ip you can find teh country and language would work for most countries except for canada etc...

cwoebker
  • 3,158
  • 5
  • 27
  • 43