Detecting browser locales/languages and generating output


 
Thread Tools Search this Thread
Top Forums Web Development Detecting browser locales/languages and generating output
# 1  
Old 02-18-2011
Detecting browser locales/languages and generating output

We have a Java app that renders Localized text on user's browser session based upon browser language settings. The app reads the browser language settings [set within the header that comes as in request to app] and prepares the localized text. But recently we faced issues for Mozilla 5.0 version browser. Note our code works fine in IE. Taking an example for 'ja' language we are expecting browser to send accepted language as 'ja-JP' [which IE does] - but unfortunately Mozilla (FF) does not - it only sends browser accepted language as 'ja'. So we land up in generating content using default language.

Since we are providing a fix for same - basically something like map [language code to language-Country code] like - 'ja' to 'ja-JP' and then create a new locale [only if 2 digits language code is present after in request] - my question is for other browsers like
Chrome
Safari
etc
What are the language formats send within headers?
So having a array say like this
ja-JP = ja-JP
ja = ja-JP
and mapping the browser language to language-country code would help to resolve the issue. But is there any specific constraint that we need to address - say are there languages that are spoken in multiple locations - if so then how would we deal with it?
Any other thing that we need to pay attention to? My request is that do we have detailed information of what accepted language all browser sends at least chrome, moziall, IE, Safari etc to compare and map values with. What is the correct way to fix this issue?

Thanks in advance.
# 2  
Old 02-18-2011
The HTTP Accept-Language request-header should conform to BCP 47 (Tags for the Identification of Languages). It is typically a two- or three-letter language code (eg. en for English), followed by optional subcodes representing such things as country (e.g. en-US represents English as used in USA). Your application should handle the various combinations and permutations of BCP 47.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Split Command Generating Incomplete Output Files

Hello All, May i please know how do i ensure my split command would NOT generate incomplete output files like below, the last lines in each file is missing some columns or last line is complete. split -b 50GB File File_ File_aa |551|70210203|xxxxxxx|12/22/2010 20:44:58|11/01/2010... (1 Reply)
Discussion started by: Ariean
1 Replies

2. Shell Programming and Scripting

Randomly selecting sequences and generating specific output files

I have two files containing hundreds of different sequences with the same Identifiers (ID-001, ID-002, etc.,), something like this: Infile1: ID-001 ATGGGAGCGGGGGCGTCTGCCTTGAGGGGAGAGAAGCTAGATACA ID-002 ATGGGAGCGGGGGCGTCTGTTTTGAGGGGAGAGAAGCTAGATACA ID-003... (18 Replies)
Discussion started by: Xterra
18 Replies

3. Shell Programming and Scripting

Setting locales

I'm having a problem with my locale setting. Essentially, when using Xmgrace or Awk, all . are replaced with , leading to wrong arithmetic. Here is an explanation of the problem: awk printing thousands with commas. see LC_ALL=en_US.UTF-8 How can I permanently set the locale... (1 Reply)
Discussion started by: chrisjorg
1 Replies

4. Shell Programming and Scripting

need help generating this output

need to check hardware error are zero iostat -en |awk '{ if ( $2 == 0 ) { print " " } else { print " Hardware errors "} } can someone please tell me whats wrong with this ---------- Post updated at 10:19 PM ---------- Previous update was at 10:16 PM ---------- iostat -en ----... (11 Replies)
Discussion started by: arch12
11 Replies

5. Shell Programming and Scripting

awk not generating the expected output

Hi, I am presently stuck in a csv file. INPUT CSV baseball,NULL,8798765,Most played baseball,NULL,8928192,Most played baseball,NULL,5678945,Most played cricket,NOTNULL,125782,Usually played cricket,NOTNULL,678921,Usually played EXPECTED OUTPUT CSV ... (7 Replies)
Discussion started by: scripter12
7 Replies

6. What is on Your Mind?

Programming languages polyglots: how many languages you know?

Post what languages (including scripting) you know, why and where you think that language is most usable. Also include libraries in which you're really good at (libusb, gtk, qt, etc). assembly? C or C++? perl or python? pascal? bash or csh/tcsh? opengl? gtk or qt? mono? (27 Replies)
Discussion started by: redoubtable
27 Replies

7. Shell Programming and Scripting

output in different languages

hello, i have to change a lot of shell scripts for one reason : the output in a script should be done in different languages. for example: echo "this is a test" and "this is a test" should be printed out in language for an example: german,italian and so. i saw a tool "gettext" ,... (2 Replies)
Discussion started by: bora99
2 Replies

8. AIX

Locales in AIX

Currently we have the following locales installed on two of our servers SERVER-1 $ locale -a C POSIX en_US en_US.8859-15 en_US.ISO8859-1 EN_US EN_US.UTF-8 ZH_CN ZH_CN.UTF-8 HI_IN HI_IN.UTF-8 ko_KR ko_KR.IBM-eucKR zh_TW zh_TW.IBM-eucTW SERVER-2 (0 Replies)
Discussion started by: voorkey
0 Replies

9. UNIX for Dummies Questions & Answers

Locales - Solaris 8

Can anyone tell me the difference between the 2 Locales: North American Partial Locales en_US.ISO8859-1 en_US.ISO8859-15 Does it matter which one to use? What are the differences? Thanks. -I have found the below info but I don't know what it means(Also no RFC# for 8859-15): ... (2 Replies)
Discussion started by: finster
2 Replies
Login or Register to Ask a Question