mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Simplify the handling of EXCLUDE_LANG_CODES
(PR 11213 follow-up)
This commit is contained in:
parent
4a5a4328f4
commit
8852991c60
1 changed files with 9 additions and 3 deletions
12
external/importL10n/locales.js
vendored
12
external/importL10n/locales.js
vendored
|
@ -46,6 +46,13 @@ function downloadLanguageCodes() {
|
||||||
response.on('end', function() {
|
response.on('end', function() {
|
||||||
content = content.trim(); // Remove any leading/trailing white-space.
|
content = content.trim(); // Remove any leading/trailing white-space.
|
||||||
var langCodes = normalizeText(content).split('\n');
|
var langCodes = normalizeText(content).split('\n');
|
||||||
|
// Remove all locales that we don't want to download below.
|
||||||
|
for (var langCode of [DEFAULT_LOCALE, ...EXCLUDE_LANG_CODES]) {
|
||||||
|
var i = langCodes.indexOf(langCode);
|
||||||
|
if (i > -1) {
|
||||||
|
langCodes.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
resolve(langCodes);
|
resolve(langCodes);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,8 +114,7 @@ async function downloadL10n(root, callback) {
|
||||||
var langCodes = await downloadLanguageCodes();
|
var langCodes = await downloadLanguageCodes();
|
||||||
|
|
||||||
for (var langCode of langCodes) {
|
for (var langCode of langCodes) {
|
||||||
if (!langCode || langCode === DEFAULT_LOCALE ||
|
if (!langCode) {
|
||||||
EXCLUDE_LANG_CODES.includes(langCode)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
await downloadLanguageFiles(root, langCode);
|
await downloadLanguageFiles(root, langCode);
|
||||||
|
@ -119,7 +125,7 @@ async function downloadL10n(root, callback) {
|
||||||
var dirPath = path.join(root, entry), stat = fs.lstatSync(dirPath);
|
var dirPath = path.join(root, entry), stat = fs.lstatSync(dirPath);
|
||||||
|
|
||||||
if (stat.isDirectory() && entry !== DEFAULT_LOCALE &&
|
if (stat.isDirectory() && entry !== DEFAULT_LOCALE &&
|
||||||
(!langCodes.includes(entry) || EXCLUDE_LANG_CODES.includes(entry))) {
|
!langCodes.includes(entry)) {
|
||||||
removeCodes.push(entry);
|
removeCodes.push(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue