detect client language
-
I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?
-
I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?
If the user's browser is set up properly, you can use
$_SERVER['HTTP_ACCEPT_LANGUAGE']
to find out which languages they prefer to use. -
If the user's browser is set up properly, you can use
$_SERVER['HTTP_ACCEPT_LANGUAGE']
to find out which languages they prefer to use.does PHP has global file similar to the global or config files in ASP.NET or I should add the language check in every php file in my website?
-
If the user's browser is set up properly, you can use
$_SERVER['HTTP_ACCEPT_LANGUAGE']
to find out which languages they prefer to use. -
when I check $_SERVER['HTTP_ACCEPT_LANGUAGE'] on Chrome it gives: "en-GB,en;q=0.8" any idea what "q=0.8" means?
My logic is impeccable; my arithmetic lets me down.
It means Microsoft estimates your command of the English language is 80%, which is pretty good actually. More here[^] :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
It means Microsoft estimates your command of the English language is 80%, which is pretty good actually. More here[^] :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Luc Pattyn wrote:
It means Microsoft estimates your command of the English language is 80%
Microsoft? Surely it must be Google Chrome who made the estimate? ...and how does it (dare it!) make that estimate?!?
My logic is impeccable; my arithmetic lets me down.
-
Luc Pattyn wrote:
It means Microsoft estimates your command of the English language is 80%
Microsoft? Surely it must be Google Chrome who made the estimate? ...and how does it (dare it!) make that estimate?!?
My logic is impeccable; my arithmetic lets me down.
You never have tried Google Translate, have you? Google knows zilch about languages. :-D
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
does PHP has global file similar to the global or config files in ASP.NET or I should add the language check in every php file in my website?
No, you would normally put anything you need to use on multiple pages into an include file, then load it on every page using
include
,require
,include_once
orrequire_once
. ... unless you are using a framework, then there should be somewhere already that you can put code to execute on each request - but that will depend on the framework. Or you could possibly skip checking it in PHP at all, and use a .htaccess file to redirect to a different path depending on the Accept-Language header. -
I want to know how can I detect the client language so if it's arabic then leave it as www.mydomain.com but if it's english then redirect to www.mydomain.com/en?
You can redirect using user's timezone also..