Merge pull request #4335 from dferer/locales-handling
Correct formatting of locale id before submitting to l10n
This commit is contained in:
commit
9c4101b51a
@ -452,16 +452,20 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
|
|
||||||
// Checks if navigator.language is supported
|
// Checks if navigator.language is supported
|
||||||
(function checkNavigatorLanguage() {
|
(function checkNavigatorLanguage() {
|
||||||
if ('language' in navigator)
|
if ('language' in navigator &&
|
||||||
|
/^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
|
||||||
return;
|
return;
|
||||||
Object.defineProperty(navigator, 'language', {
|
}
|
||||||
get: function navigatorLanguage() {
|
function formatLocale(locale) {
|
||||||
var language = navigator.userLanguage || 'en-US';
|
var split = locale.split(/[-_]/);
|
||||||
return language.substring(0, 2).toLowerCase() +
|
split[0] = split[0].toLowerCase();
|
||||||
language.substring(2).toUpperCase();
|
if (split.length > 1) {
|
||||||
},
|
split[1] = split[1].toUpperCase();
|
||||||
enumerable: true
|
}
|
||||||
});
|
return split.join('-');
|
||||||
|
}
|
||||||
|
var language = navigator.language || navigator.userLanguage || 'en-US';
|
||||||
|
PDFJS.locale = formatLocale(language);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(function checkRangeRequests() {
|
(function checkRangeRequests() {
|
||||||
|
@ -1666,7 +1666,7 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL)
|
//#if !(FIREFOX || MOZCENTRAL)
|
||||||
var locale = navigator.language;
|
var locale = PDFJS.locale || navigator.language;
|
||||||
if ('locale' in hashParams)
|
if ('locale' in hashParams)
|
||||||
locale = hashParams['locale'];
|
locale = hashParams['locale'];
|
||||||
mozL10n.setLanguage(locale);
|
mozL10n.setLanguage(locale);
|
||||||
|
Loading…
Reference in New Issue
Block a user