Questions tagged [http-accept-language]

Questions related to the Accept Language request header field of HTTP

99 questions
44
votes
7 answers

Parse Accept-Language header in Java

The accept-language header in request is usually a long complex string - Eg. Accept-Language : en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2 Is there a simple way to parse it in java? Or a API to help me do that?
Pushkar
  • 7,450
  • 10
  • 38
  • 57
42
votes
3 answers

How to add custom Accept-Languages to Chrome for pseudolocalization testing?

i am testing pseudo-localization of a web-site. i can configure Internet Explorer to have custom accept languages: Click Tools, Internet Options On the General tab click Languages In the Language Preferences dialog click Add. Enter a user-defined…
18
votes
1 answer

Python change Accept-Language using requests

I'm new to python and trying to get some infos from IMDb using requests library. My code is capturing all data (e.g., movie titles) in my native language, but i would like to get them in english. How can i change the accept-language in requests to…
mihasa
  • 967
  • 2
  • 10
  • 20
18
votes
1 answer

Why does Symfony ignore the browsers locale-setting (HTTP-Request Accept-Language Header)?

i am currently trying to enable the translator in Symfony 2.0. Symfony is ignoring the Accept-Language Header variable and is using default_locale (and when that is not defined the fallback). My request looks like: Accept-Language…
Senči
  • 911
  • 2
  • 10
  • 25
17
votes
4 answers

cUrl set language header

How can I set a language header for my cURL request? e.g. now I get the homepage of facebook.com in dutch, probably because my server is in the Netherlands / default language send by headers?.. I prefer english before dutch in this case so I tried…
directory
  • 3,093
  • 8
  • 45
  • 85
15
votes
2 answers

Accept Language list

I would like to react to the Accept_Language that a browser sends to a website. Does anybody know where I can get a reliable list of all available Accept_Languages that the browser might send to a website? Thank you very much!
tmighty
  • 10,734
  • 21
  • 104
  • 218
13
votes
2 answers

How to make a file field that only accept pdf and doc

I need to accept only pdf and doc file using input type file. This is working in windows, but in ubunthu, it only accept pdf file
Vineetha K D
  • 211
  • 1
  • 5
  • 13
11
votes
3 answers

Accuracy of accept_language to detect country

I need to detect the country of users but I'm trying to avoid the whole call to an external service to get the location based on IP or to an internal database. I need to make this service really responsive and it takes almost half a second to query…
Martin
  • 11,216
  • 23
  • 83
  • 140
10
votes
4 answers

How to get Default language of browser in Django?

I want to fetch default language of browser. I have tried some code for this but nothing works for me correctly . I can get an array of all languages that are activated in browser from this request.META['HTTP_ACCEPT_LANGUAGE']. But how I can get…
n.imp
  • 787
  • 4
  • 11
  • 29
9
votes
0 answers

Get browser Accept-Language header value for a fetch request

I just realized that fetch does not send Accept-Language header by default, therefore I plan to add that. However, I haven't come across any way to get the string that the browser should generate. For example, in my browser, all normal requests have…
Luke Vo
  • 17,859
  • 21
  • 105
  • 181
9
votes
3 answers

REST API request with language and region

I'm developing a REST API and I need to implement a method which needs language and country to produce result in the correct format since the result contains numbers and dates. I was using the HTTP Accept-Language header to get the language. The…
Filipo Red
  • 91
  • 1
  • 1
  • 3
9
votes
6 answers

Language redirect works on desktop but not mobile browser

I've put together a small script in PHP that checks for the browser's language settings and redirect them to a language version of the site (WP multisite), function redirect() { $language = substr( $_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2 ); switch(…
Staffan Estberg
  • 6,795
  • 16
  • 71
  • 107
6
votes
1 answer

Set Accepted-Lang for Chrome Headless with Selenium (Python)

Setting the Accepted-Lang header works fine with regular Chrome via ChromeOptions options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'}) I'm trying to switch to new headless Chrome, but apparently this option has no effect…
6
votes
2 answers

Does the order of the languages matter in the HTTP Accept-language field?

I was wondering if the order of the actual languages in the Accept-language matters. For example, if our HTTP GET message contained the header: Accept-Language: en-us, en-gb;q=0.2, en;q=0.3, fr, fr-ch, da, fi ...would the browser prefer Traditional…
user2159121
  • 135
  • 1
  • 7
4
votes
1 answer

Why language.Matcher returns such strange result?

I am implementing a multilang web service based on Accept-Language header. I use next code for parsing header and getting the requested language: var matcher = language.NewMatcher([]language.Tag{ language.English, …
skeeph
  • 462
  • 2
  • 6
  • 18
1
2 3 4 5 6 7