I am implementing i18n in my webapp and am in the testing phase at the moment. I am using java.util.Locale
on the server side to pass the locale to the relevant APIs (date time etc) that consume the information. Here is my setup:
- browser language has been set to "Hindi"
- operating System country has been set to "India"
- I send a request to the server expecting the "Accept-Language" header to be
hi-IN
but the value remainshi
regardless of country setting on my OS ... actual valueAccept-Language:hi;en-US,en;q=0.8,q=0.6
- my webapp uses the incoming value in the request header and does i18n or l10n accordingly by loading the appropriate language translation from resource files
- I have a test case where I manually send in
new Locale("hi", "IN")
to indicate language and country. This test case prints values in the correct language as I expect but since the value coming in from the request is onlyhi
, I am unable to see the desired result.
Not sure why the browsers (Chrome and Firefox) do not support the language_country
format for all entries in their selection. Is there anything I am missing?
Edit: I made a few corrections based on the answer by @pawel-dyda. To quote a part of his reponse
Your language tag should be hi-IN, which I believe should explain the odd behaviour.
The crux of the issue (the reason I am raising this question here) is that I am unable to get my browser to send the value hi-IN
to the server in the Accept-Language
header.