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.

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.