>How can I get language of the system where PHP is installed in RFC1766
>convention from PHP?
setlocale()
Hmm it appears that I've asked the wrong question. Now I realize that
what I really want is a client's browser locale. For example
general.userage nt.locale setting in Firefox. Can I get this RFC1766 from
user's browser in PHP somehow without using Javascript?
On Wed, 25 Jul 2007 14:51:29 +0200, Sergei Riaguzov <hello@world.co m>
wrote:
On Wed, 25 Jul 2007 10:59:21 +0000, Sjoerd wrote:
>
>>How can I get language of the system where PHP is installed in RFC1766
>>convention from PHP?
>setlocale()
Hmm it appears that I've asked the wrong question. Now I realize that
what I really want is a client's browser locale. For example
general.userage nt.locale setting in Firefox. Can I get this RFC1766 from
user's browser in PHP somehow without using Javascript?
The only thing I know about that hat makes sense to use is the
HTTP_ACCEPT_LAN GUAGE header in the request, which may or may not be sent.
--
Rik Wasmus
On Wed, 25 Jul 2007 15:02:40 +0200, Sergei Riaguzov <hello@world.co m
wrote:
On Wed, 25 Jul 2007 14:54:38 +0200, Rik wrote:
>
>The only thing I know about that hat makes sense to use is the
>HTTP_ACCEPT_LA NGUAGE header in the request, which may or may not be
>sent.
That's not it..
>
I have set general.userage nt.locale to "en" in Firefox but what I get
from $_SERVER["HTTP_ACCEPT_LA NGUAGE"] is "pl,en-us;q=0.7,en;q=0 .3"
That's because you've set polish as your preferred language
(tools->options->advanced->languages->Choose.. ). That's how I come by
fairly large:
It might help if you told us what the locale is going to be used for? I
guessed for determening the language of the user, but I might be wrong..
And the users themselves might not have it set correctly offcourse.
Standard for most browsers is using the language of the OS as default on
install however, so normally it would be pretty reliable.
--
Rik Wasmus
>I have set general.userage nt.locale to "en" in Firefox but what I get
>from $_SERVER["HTTP_ACCEPT_LA NGUAGE"] is "pl,en-us;q=0.7,en;q=0 .3"
That's because you've set polish as your preferred language
(tools->options->advanced->languages->Choose.. ). That's how I come by
fairly large:
Accept-Language: en-gb,en;q=0.8,nl; q=0.7,nl-be;q=0.5,de;q=0 .3,fr;q=0.2
And which one should be user locale? The first one?
It might help if you told us what the locale is going to be used for? I
guessed for determening the language of the user, but I might be wrong..
And the users themselves might not have it set correctly offcourse.
Yes that's right, I want to find out user locale settings to show
localized page.
On Wed, 25 Jul 2007 16:57:03 +0200, Sergei Riaguzov <hello@world.co m
wrote:
On Wed, 25 Jul 2007 15:24:01 +0200, Rik wrote:
>
>>I have set general.userage nt.locale to "en" in Firefox but what I get
>>from $_SERVER["HTTP_ACCEPT_LA NGUAGE"] is "pl,en-us;q=0.7,en;q=0 .3"
>That's because you've set polish as your preferred language
>(tools->options->advanced->languages->Choose.. ). That's how I come by
>fairly large:
>Accept-Language: en-gb,en;q=0.8,nl; q=0.7,nl-be;q=0.5,de;q=0 .3,fr;q=0.2
And which one should be user locale? The first one?
None of the above, it has very little to do with the locale. The first one
(with q=1, so omitted, choose the highest q), would be the preferred
language as set in the browser. If users haven't touched it, it's usually
follows the locale they've set. If they have, they usually know what
they're doing.
>It might help if you told us what the locale is going to be used for?I
>guessed for determening the language of the user, but I might be wrong..
>And the users themselves might not have it set correctly offcourse.
Yes that's right, I want to find out user locale settings to show
localized page.
Localized on location/region, or language? HTTP_ACCEPT_LAN GUAGE is only
usefull for language, in other cases you'll have to look into stuff like
GeoIP.
>
And which one should be user locale? The first one?
The Accept-Language header doesn't tell you anything about the client
machine's locale. The client machine's locale is sometimes given in the
HTTP User-Agent header, but not always.
The Accept-Language header shows the client's preferred language. This may
not always be the same as the machine's locale. Say, for example, that the
user is fluent in Flemish, he might set Flemish to be his first choice of
Accept-Language, but his machine's locale may be French, because no
Flemish translation of the software is available.
Note that you don't always have to pick the first language on the list.
Say for example, I have a site that's in English; I've made a French
translation using an automatic service, but I'm under no illusions about
the quality of the translation. If a user comes along with a header like
this:
Accept-Language: fr
I'd probably serve up the poorly translated French version, with my
apologies. But if the header was like this:
Accept-Language: fr, en
I might send the English version, because even though the visitor prefers
French, I know my translation'sno t up to scratch.
(Note that Apache is able to deal make these decisions itself. You just
tell it which translations of the content are available, and of what
quality they each are, and it will make the choice which version to serve.)
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 35 days, 1:43.]
On Wed, 25 Jul 2007 23:20:39 +0100, Toby A Inkster wrote:
Accept-Language: fr
>
I'd probably serve up the poorly translated French version, with my
apologies. But if the header was like this:
>
Accept-Language: fr, en
Thanx for your answers, it becomes much clearer now!
PS Sorry for another username, I have some other settings at home.
Comment