By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,398 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,398 IT Pros & Developers. It's quick & easy.

RFC 1766

P: n/a
Hi,

How can I get language of the system where PHP is installed in RFC1766
convention from PHP?
Jul 25 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On Jul 25, 12:28 pm, Sergei Riaguzov <he...@world.comwrote:
How can I get language of the system where PHP is installed in RFC1766
convention from PHP?
setlocale()

Jul 25 '07 #2

P: n/a
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()
Thanx!
Jul 25 '07 #3

P: n/a
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.useragent.locale setting in Firefox. Can I get this RFC1766 from
user's browser in PHP somehow without using Javascript?
Jul 25 '07 #4

P: n/a
Rik
On Wed, 25 Jul 2007 14:51:29 +0200, Sergei Riaguzov <he***@world.com>
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.useragent.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_LANGUAGE header in the request, which may or may not be sent.
--
Rik Wasmus
Jul 25 '07 #5

P: n/a
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_LANGUAGE header in the request, which may or may not be
sent.
That's not it..

I have set general.useragent.locale to "en" in Firefox but what I get
from $_SERVER["HTTP_ACCEPT_LANGUAGE"] is "pl,en-us;q=0.7,en;q=0.3"
Jul 25 '07 #6

P: n/a
Rik
On Wed, 25 Jul 2007 15:02:40 +0200, Sergei Riaguzov <he***@world.com
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_LANGUAGE header in the request, which may or may not be
sent.
That's not it..

I have set general.useragent.locale to "en" in Firefox but what I get
from $_SERVER["HTTP_ACCEPT_LANGUAGE"] 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

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
Jul 25 '07 #7

P: n/a
On Wed, 25 Jul 2007 15:24:01 +0200, Rik wrote:
>I have set general.useragent.locale to "en" in Firefox but what I get
from $_SERVER["HTTP_ACCEPT_LANGUAGE"] 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.
Jul 25 '07 #8

P: n/a
Rik
On Wed, 25 Jul 2007 16:57:03 +0200, Sergei Riaguzov <he***@world.com
wrote:
On Wed, 25 Jul 2007 15:24:01 +0200, Rik wrote:
>>I have set general.useragent.locale to "en" in Firefox but what I get
from $_SERVER["HTTP_ACCEPT_LANGUAGE"] 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_LANGUAGE is only
usefull for language, in other cases you'll have to look into stuff like
GeoIP.

--
Rik Wasmus
Jul 25 '07 #9

P: n/a
Sergei Riaguzov wrote:
Rik wrote:
>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?
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'snot 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.]

Cryptography Challenge
http://tobyinkster.co.uk/blog/2007/0...pto-challenge/
Jul 25 '07 #10

P: n/a
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.
Jul 26 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.