Content negotiation with language subtags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Im am using content negotiation to present different HTML pages
depending on the browsers language preference. This works in general,
but not with language "subtags", e.g. if the preferred language is sent
as "de-DE" only.

Here is my setup (reduced to two languages for simplicity):
----------------------------------------------
// .htaccess:
AddHandler type-map var
DirectoryIndex index.var
LanguagePriority en de
ForceLanguagePriority Prefer Fallback

// index.var:
URI: index

URI: index.en.html
Content-type: text/html
Content-language: en

URI: index.de.html
Content-type: text/html
Content-language: de

// index.en.html: English index page
// index.de.html: German index page
----------------------------------------------

This works as expected when the client sends the preferred language as

   Accept-Language: de,en;q=0.8

and "index.de.html" is returned from the Apache server. But with

   Accept-Language: de-DE,en-US;q=0.8

the server returns "index.en.html", so apparently "de-DE" does not match
"de" when the language is negotiated.

Do I really have to add all possible combinations in "index.var", such
as "de, de-DE, de-CH, de-AT" for German? Or is there at way to specify
"match this language with any language subtags"? My naive approach
"de-*" did not work.

Or is it a bug in the HTTP client (in my case: Android WebView) if it
sends only "de-DE" in the Accept-Language header, without a plain "de"?

Thanks for any help,
Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux