Questions tagged [http-accept-language]

Questions related to the Accept Language request header field of HTTP

99 questions
4
votes
2 answers

Which format of "en_US" and "en-US" should be used in Http header request as Accept-Language?

I actually tested these two formats and my server is okay with both. Since Http header fields is saying "en-US" is the format and my Local java class is returning "en_US", I'm little bit confused to get which of them to use! My partial code is like…
Hesam
  • 52,260
  • 74
  • 224
  • 365
4
votes
1 answer

Detect if user is using browser with RTL language

How can I detect in my webpage using javascript if the user is using a browser with RTL language? For example Arabic. I want to provide a different layout for them.
user445338
4
votes
2 answers

Google crawl error with HTTP_ACCEPT_LANGUAGE

In my Codeigniter app I use $_SERVER['HTTP_ACCEPT_LANGUAGE'] to determine the users browser language to set the app language based on that, like that: public function __construct() { parent::__construct(); /* set session language if not set. "hu"…
Malvolio
  • 366
  • 1
  • 5
  • 19
4
votes
2 answers

Rails I18n: setting initial locale from HTTP_ACCEPT_LANGUAGE

Thanks everyone for your help. WHAT I AM DOING: I'm designing a corporate website which must be available in multiple languages WHAT I HAVE DONE: A rails application with several static pages. I used Ryan Bates example on using I18n features in…
3
votes
1 answer

Swagger 2.0 Accept-Language header as request parameter

I'm writing a specification for a http API using Swagger 2.0. How can I define the Accept-Language header as a required header parameter for a path? /aPath: post: parameters: - in: header name: Accept-Language type: string …
Osvald Laurits
  • 1,228
  • 2
  • 17
  • 32
3
votes
1 answer

How to interpret multiple Accept-* headers

My reading of RFC 2616 hasn't answered my question: How should a server interpret multiple Accept, Accept-Encoding, Accept-Language, etc, headers? Granted, this should generally be a rare occurrence, but far be it from me to assume every HTTP client…
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
3
votes
2 answers

Support only a limited number of languages

My API uses Jersey 2, and now I want to support internationalization. I understand my client should specify the Accept-Language parameter, but I want to understand how to handle it properly. Let's assume that my API should handle only FRENCH and…
3
votes
2 answers

Varnish redirect based on browser language settings

I am using varnish 4 in front of apache. I need requests made to deutsh.de coming from headers with the preferred language es or ca (unless it also has de or en) to be redirected to spanish.es. Could somebody provide me with the appropriate…
bfilip
  • 69
  • 8
3
votes
2 answers

Spring MVC: redirect user according to browser language

In Spring MVC 4 how can I redirect the user to a localized url according to the browser language (the HTTP header "Accept-Language")? I would that if an user is trying to access the url example.com/some/path it will redirect to…
Andrea
  • 15,900
  • 18
  • 65
  • 84
3
votes
1 answer

Automatically Translate Website With Google Translate Plugin (IP & Accept-Language)?

Is there a way to translate my website automatically based on the visitor's IP and "accept-language" header information using Google Translate Plug-in? Thank you!
3
votes
2 answers

Python - Extract Main Language Code from HTTP / Browser

I need a way to determine the main language set in a browser. I found a really great solution for PHP but unfortunately I'm using Django / Python. I think the information is within the HTTP_ACCEPT_LANGUAGE attribute of the HTTP Request. Any ideas or…
Ron
  • 22,128
  • 31
  • 108
  • 206
2
votes
0 answers

Accepted-Language Preference Order: What if the Wildcard Comes First?

Let's say I am writing a server which can handle a language set [en-US, en-GB]. Now, there is a request whose Accept-Language is en, en-US. Does it mean the user prefer en-GB rather than en-US? Or is this a valid case to send to the server? The only…
Checkwhei Sin
  • 166
  • 1
  • 11
2
votes
2 answers

PHP or htaccess rewrite URL by Accept-Language?

I've my site set up so I just need to add "?lang=en" or "?lang=es" to change languages English / Spanish. When I enter the site with, for ex, "http://domain.com/something/something_else?lang=es", a cookie is set so I continue to navigate the site in…
Santiago
  • 2,405
  • 6
  • 31
  • 43
2
votes
1 answer

How to add global header parameter to all url paths in drf_spectacular?

I'm using drf_spectacular to be able to use swagger and it's working fine. I define the required parameters for my API views (whether in the path or in the header) like this: @extend_schema( OpenApiParameter( name='accept-language', …
2
votes
1 answer

ColdFusion error retrieving accept-language from GetHttpRequestData().headers

I'm attempting to pull the variable GetHttpRequestData().headers.accept-language in ColdFusion 2018, but am getting an error. The main object GetHttpRequestData().headers looks fine. This is information from the html request header. I can also pull…