mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Merge pull request #5692 from Rob--W/webl10n-fix
[l10n] Treat language as case-insensitive
This commit is contained in:
commit
da258f8972
2 changed files with 26 additions and 16 deletions
|
@ -447,20 +447,10 @@ if (typeof PDFJS === 'undefined') {
|
|||
|
||||
// Checks if navigator.language is supported
|
||||
(function checkNavigatorLanguage() {
|
||||
if ('language' in navigator &&
|
||||
/^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
|
||||
if ('language' in navigator) {
|
||||
return;
|
||||
}
|
||||
function formatLocale(locale) {
|
||||
var split = locale.split(/[-_]/);
|
||||
split[0] = split[0].toLowerCase();
|
||||
if (split.length > 1) {
|
||||
split[1] = split[1].toUpperCase();
|
||||
}
|
||||
return split.join('-');
|
||||
}
|
||||
var language = navigator.language || navigator.userLanguage || 'en-US';
|
||||
PDFJS.locale = formatLocale(language);
|
||||
PDFJS.locale = navigator.userLanguage || 'en-US';
|
||||
})();
|
||||
|
||||
(function checkRangeRequests() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue