From 2b407990e22765e76c7d1de0a2808ec31f0691ea Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 22 Feb 2024 13:24:12 +0100 Subject: [PATCH 1/2] Use the Fetch API to download the l10n files Given that the Fetch API is supported since Node.js 18 we should be able to use it when downloading l10n files, which allows us to simplify the code and to make it fully `async`. --- external/importL10n/locales.mjs | 88 +++++++++++---------------------- 1 file changed, 30 insertions(+), 58 deletions(-) diff --git a/external/importL10n/locales.mjs b/external/importL10n/locales.mjs index 7883e0977..62264d3ff 100644 --- a/external/importL10n/locales.mjs +++ b/external/importL10n/locales.mjs @@ -14,7 +14,6 @@ */ import fs from "fs"; -import https from "https"; import path from "path"; // Fetches all languages that have an *active* translation in mozilla-central. @@ -22,47 +21,34 @@ import path from "path"; const DEFAULT_LOCALE = "en-US"; -const EXCLUDE_LANG_CODES = ["ca-valencia", "ja-JP-mac"]; +const EXCLUDE_LANG_CODES = new Set(["ca-valencia", "ja-JP-mac"]); function normalizeText(s) { return s.replaceAll(/\r\n?/g, "\n").replaceAll("\uFEFF", ""); } -function downloadLanguageCodes() { +async function downloadLanguageCodes() { console.log("Downloading language codes...\n"); const ALL_LOCALES = "https://hg.mozilla.org/mozilla-central/raw-file/tip/browser/locales/all-locales"; - return new Promise(function (resolve) { - https.get(ALL_LOCALES, function (response) { - if (response.statusCode === 200) { - let content = ""; - response.setEncoding("utf8"); - response.on("data", function (chunk) { - content += chunk; - }); - response.on("end", function () { - content = content.trim(); // Remove any leading/trailing white-space. - const langCodes = normalizeText(content).split("\n"); - // Remove all locales that we don't want to download below. - for (const langCode of [DEFAULT_LOCALE, ...EXCLUDE_LANG_CODES]) { - const i = langCodes.indexOf(langCode); - if (i > -1) { - langCodes.splice(i, 1); - } - } - resolve(langCodes); - }); - } else { - resolve([]); - } - }); - }); + const response = await fetch(ALL_LOCALES); + if (!response.ok) { + throw new Error(response.statusText); + } + const content = await response.text(); + + // Remove any leading/trailing white-space. + const langCodes = normalizeText(content.trim()).split("\n"); + // Remove all locales that we don't want to download below. + return langCodes.filter( + langCode => langCode !== DEFAULT_LOCALE && !EXCLUDE_LANG_CODES.has(langCode) + ); } -function downloadLanguageFiles(root, langCode) { - console.log("Downloading " + langCode + "..."); +async function downloadLanguageFiles(root, langCode) { + console.log(`Downloading ${langCode}...`); // Constants for constructing the URLs. Translations are taken from the // Nightly channel as those are the most recent ones. @@ -71,41 +57,27 @@ function downloadLanguageFiles(root, langCode) { // Defines which files to download for each language. const files = ["viewer.ftl"]; - let downloadsLeft = files.length; const outputDir = path.join(root, langCode); if (!fs.existsSync(outputDir)) { fs.mkdirSync(outputDir); } - return new Promise(function (resolve) { - // Download the necessary files for this language. - files.forEach(function (fileName) { - const outputPath = path.join(outputDir, fileName); - const url = - MOZ_CENTRAL_ROOT + langCode + MOZ_CENTRAL_PDFJS_DIR + fileName; + // Download the necessary files for this language. + for (const fileName of files) { + const outputPath = path.join(outputDir, fileName); + const url = MOZ_CENTRAL_ROOT + langCode + MOZ_CENTRAL_PDFJS_DIR + fileName; - https.get(url, function (response) { - // Not all files exist for each language. Files without translations - // have been removed (https://bugzilla.mozilla.org/show_bug.cgi?id=1443175). - if (response.statusCode === 200) { - let content = ""; - response.setEncoding("utf8"); - response.on("data", function (chunk) { - content += chunk; - }); - response.on("end", function () { - fs.writeFileSync(outputPath, normalizeText(content), "utf8"); - if (--downloadsLeft === 0) { - resolve(); - } - }); - } else if (--downloadsLeft === 0) { - resolve(); - } - }); - }); - }); + const response = await fetch(url); + if (!response.ok) { + // Not all files exist for each language. Files without translations + // have been removed (https://bugzilla.mozilla.org/show_bug.cgi?id=1443175). + continue; + } + const content = await response.text(); + + fs.writeFileSync(outputPath, normalizeText(content), "utf8"); + } } async function downloadL10n(root) { From ea4b55a0e6cb82bc4fae948ac42f73ab46ff7ef7 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 22 Feb 2024 13:24:20 +0100 Subject: [PATCH 2/2] Update l10n files --- l10n/br/viewer.ftl | 10 ++++++++++ l10n/es-ES/viewer.ftl | 6 ++++-- l10n/eu/viewer.ftl | 6 ++++-- l10n/gl/viewer.ftl | 17 +++++++++++++++++ l10n/it/viewer.ftl | 2 -- l10n/nb-NO/viewer.ftl | 5 +++++ l10n/pt-PT/viewer.ftl | 40 ++++++++++++++++++++++++++++++++++++++++ l10n/sl/viewer.ftl | 6 ++++-- l10n/th/viewer.ftl | 4 ++++ l10n/uk/viewer.ftl | 2 +- 10 files changed, 89 insertions(+), 9 deletions(-) diff --git a/l10n/br/viewer.ftl b/l10n/br/viewer.ftl index 4cdd3b8d8..9049f68f1 100644 --- a/l10n/br/viewer.ftl +++ b/l10n/br/viewer.ftl @@ -274,6 +274,9 @@ pdfjs-editor-free-text-button-label = Testenn pdfjs-editor-ink-button = .title = Tresañ pdfjs-editor-ink-button-label = Tresañ +pdfjs-editor-stamp-button = + .title = Ouzhpennañ pe aozañ skeudennoù +pdfjs-editor-stamp-button-label = Ouzhpennañ pe aozañ skeudennoù ## Remove button for the various kind of editor. @@ -289,9 +292,16 @@ pdfjs-editor-ink-opacity-input = Boullder pdfjs-editor-stamp-add-image-button = .title = Ouzhpennañ ur skeudenn pdfjs-editor-stamp-add-image-button-label = Ouzhpennañ ur skeudenn +pdfjs-free-text = + .aria-label = Aozer testennoù +pdfjs-ink = + .aria-label = Aozer tresoù +pdfjs-ink-canvas = + .aria-label = Skeudenn bet krouet gant an implijer·ez ## Alt-text dialog +pdfjs-editor-alt-text-add-description-label = Ouzhpennañ un deskrivadur pdfjs-editor-alt-text-cancel-button = Nullañ pdfjs-editor-alt-text-save-button = Enrollañ diff --git a/l10n/es-ES/viewer.ftl b/l10n/es-ES/viewer.ftl index 095546c00..bdd3b31c5 100644 --- a/l10n/es-ES/viewer.ftl +++ b/l10n/es-ES/viewer.ftl @@ -301,8 +301,6 @@ pdfjs-editor-ink-button-label = Dibujar pdfjs-editor-stamp-button = .title = Añadir o editar imágenes pdfjs-editor-stamp-button-label = Añadir o editar imágenes -pdfjs-editor-remove-button = - .title = Eliminar pdfjs-editor-highlight-button = .title = Resaltar pdfjs-editor-highlight-button-label = Resaltar @@ -329,6 +327,10 @@ pdfjs-editor-ink-opacity-input = Opacidad pdfjs-editor-stamp-add-image-button = .title = Añadir imagen pdfjs-editor-stamp-add-image-button-label = Añadir imagen +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = Grosor +pdfjs-editor-free-highlight-thickness-title = + .title = Cambiar el grosor al resaltar elementos que no sean texto pdfjs-free-text = .aria-label = Editor de texto pdfjs-free-text-default-content = Empezar a escribir… diff --git a/l10n/eu/viewer.ftl b/l10n/eu/viewer.ftl index 7c3860267..8fc5e7b31 100644 --- a/l10n/eu/viewer.ftl +++ b/l10n/eu/viewer.ftl @@ -301,8 +301,6 @@ pdfjs-editor-ink-button-label = Marrazkia pdfjs-editor-stamp-button = .title = Gehitu edo editatu irudiak pdfjs-editor-stamp-button-label = Gehitu edo editatu irudiak -pdfjs-editor-remove-button = - .title = Kendu pdfjs-editor-highlight-button = .title = Nabarmendu pdfjs-editor-highlight-button-label = Nabarmendu @@ -329,6 +327,10 @@ pdfjs-editor-ink-opacity-input = Opakutasuna pdfjs-editor-stamp-add-image-button = .title = Gehitu irudia pdfjs-editor-stamp-add-image-button-label = Gehitu irudia +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = Loditasuna +pdfjs-editor-free-highlight-thickness-title = + .title = Aldatu loditasuna testua ez beste elementuak nabarmentzean pdfjs-free-text = .aria-label = Testu-editorea pdfjs-free-text-default-content = Hasi idazten… diff --git a/l10n/gl/viewer.ftl b/l10n/gl/viewer.ftl index 1b732fd4c..a08fb1a3a 100644 --- a/l10n/gl/viewer.ftl +++ b/l10n/gl/viewer.ftl @@ -301,6 +301,18 @@ pdfjs-editor-ink-button-label = Debuxo pdfjs-editor-stamp-button = .title = Engadir ou editar imaxes pdfjs-editor-stamp-button-label = Engadir ou editar imaxes + +## Remove button for the various kind of editor. + +pdfjs-editor-remove-freetext-button = + .title = Eliminar o texto +pdfjs-editor-remove-stamp-button = + .title = Eliminar a imaxe +pdfjs-editor-remove-highlight-button = + .title = Eliminar o resaltado + +## + # Editor Parameters pdfjs-editor-free-text-color-input = Cor pdfjs-editor-free-text-size-input = Tamaño @@ -310,6 +322,8 @@ pdfjs-editor-ink-opacity-input = Opacidade pdfjs-editor-stamp-add-image-button = .title = Engadir imaxe pdfjs-editor-stamp-add-image-button-label = Engadir imaxe +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = Grosor pdfjs-free-text = .aria-label = Editor de texto pdfjs-free-text-default-content = Comezar a teclear… @@ -345,3 +359,6 @@ pdfjs-editor-resizer-label-bottom-right = Esquina inferior dereita: cambia o tam pdfjs-editor-resizer-label-bottom-middle = Abaixo medio: cambia o tamaño pdfjs-editor-resizer-label-bottom-left = Esquina inferior esquerda: cambia o tamaño pdfjs-editor-resizer-label-middle-left = Medio esquerdo: cambia o tamaño + +## Color picker + diff --git a/l10n/it/viewer.ftl b/l10n/it/viewer.ftl index 7daf38be6..2f205fe19 100644 --- a/l10n/it/viewer.ftl +++ b/l10n/it/viewer.ftl @@ -321,8 +321,6 @@ pdfjs-editor-remove-highlight-button = ## -pdfjs-editor-remove-button = - .title = Rimuovi # Editor Parameters pdfjs-editor-free-text-color-input = Colore pdfjs-editor-free-text-size-input = Dimensione diff --git a/l10n/nb-NO/viewer.ftl b/l10n/nb-NO/viewer.ftl index 244cbd4c3..0d7c61f3f 100644 --- a/l10n/nb-NO/viewer.ftl +++ b/l10n/nb-NO/viewer.ftl @@ -301,6 +301,9 @@ pdfjs-editor-ink-button-label = Tegn pdfjs-editor-stamp-button = .title = Legg til eller rediger bilder pdfjs-editor-stamp-button-label = Legg til eller rediger bilder +pdfjs-editor-highlight-button = + .title = Markere +pdfjs-editor-highlight-button-label = Markere ## Remove button for the various kind of editor. @@ -326,6 +329,8 @@ pdfjs-editor-stamp-add-image-button = pdfjs-editor-stamp-add-image-button-label = Legg til bilde # This refers to the thickness of the line used for free highlighting (not bound to text) pdfjs-editor-free-highlight-thickness-input = Tykkelse +pdfjs-editor-free-highlight-thickness-title = + .title = Endre tykkelse når du markerer andre elementer enn tekst pdfjs-free-text = .aria-label = Tekstredigering pdfjs-free-text-default-content = Begynn å skrive… diff --git a/l10n/pt-PT/viewer.ftl b/l10n/pt-PT/viewer.ftl index fc4d31a51..3b36846fd 100644 --- a/l10n/pt-PT/viewer.ftl +++ b/l10n/pt-PT/viewer.ftl @@ -301,6 +301,23 @@ pdfjs-editor-ink-button-label = Desenhar pdfjs-editor-stamp-button = .title = Adicionar ou editar imagens pdfjs-editor-stamp-button-label = Adicionar ou editar imagens +pdfjs-editor-highlight-button = + .title = Destaque +pdfjs-editor-highlight-button-label = Destaque + +## Remove button for the various kind of editor. + +pdfjs-editor-remove-ink-button = + .title = Remover desenho +pdfjs-editor-remove-freetext-button = + .title = Remover texto +pdfjs-editor-remove-stamp-button = + .title = Remover imagem +pdfjs-editor-remove-highlight-button = + .title = Remover destaque + +## + # Editor Parameters pdfjs-editor-free-text-color-input = Cor pdfjs-editor-free-text-size-input = Tamanho @@ -310,6 +327,10 @@ pdfjs-editor-ink-opacity-input = Opacidade pdfjs-editor-stamp-add-image-button = .title = Adicionar imagem pdfjs-editor-stamp-add-image-button-label = Adicionar imagem +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = Espessura +pdfjs-editor-free-highlight-thickness-title = + .title = Alterar espessura quando destacar itens que não sejam texto pdfjs-free-text = .aria-label = Editor de texto pdfjs-free-text-default-content = Começar a digitar… @@ -347,3 +368,22 @@ pdfjs-editor-resizer-label-bottom-right = Canto inferior direito — redimension pdfjs-editor-resizer-label-bottom-middle = Inferior ao centro — redimensionar pdfjs-editor-resizer-label-bottom-left = Canto inferior esquerdo — redimensionar pdfjs-editor-resizer-label-middle-left = Centro à esquerda — redimensionar + +## Color picker + +# This means "Color used to highlight text" +pdfjs-editor-highlight-colorpicker-label = Cor de destaque +pdfjs-editor-colorpicker-button = + .title = Alterar cor +pdfjs-editor-colorpicker-dropdown = + .aria-label = Escolhas de cor +pdfjs-editor-colorpicker-yellow = + .title = Amarelo +pdfjs-editor-colorpicker-green = + .title = Verde +pdfjs-editor-colorpicker-blue = + .title = Azul +pdfjs-editor-colorpicker-pink = + .title = Rosa +pdfjs-editor-colorpicker-red = + .title = Vermelho diff --git a/l10n/sl/viewer.ftl b/l10n/sl/viewer.ftl index 4a4a2a092..dc3ec02f2 100644 --- a/l10n/sl/viewer.ftl +++ b/l10n/sl/viewer.ftl @@ -305,8 +305,6 @@ pdfjs-editor-ink-button-label = Riši pdfjs-editor-stamp-button = .title = Dodajanje ali urejanje slik pdfjs-editor-stamp-button-label = Dodajanje ali urejanje slik -pdfjs-editor-remove-button = - .title = Odstrani pdfjs-editor-highlight-button = .title = Poudarek pdfjs-editor-highlight-button-label = Poudarek @@ -333,6 +331,10 @@ pdfjs-editor-ink-opacity-input = Neprosojnost pdfjs-editor-stamp-add-image-button = .title = Dodaj sliko pdfjs-editor-stamp-add-image-button-label = Dodaj sliko +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = Debelina +pdfjs-editor-free-highlight-thickness-title = + .title = Spremeni debelino pri označevanju nebesedilnih elementov pdfjs-free-text = .aria-label = Urejevalnik besedila pdfjs-free-text-default-content = Začnite tipkati … diff --git a/l10n/th/viewer.ftl b/l10n/th/viewer.ftl index 2d3fb6975..ea45c1ae5 100644 --- a/l10n/th/viewer.ftl +++ b/l10n/th/viewer.ftl @@ -319,6 +319,10 @@ pdfjs-editor-ink-opacity-input = ความทึบ pdfjs-editor-stamp-add-image-button = .title = เพิ่มภาพ pdfjs-editor-stamp-add-image-button-label = เพิ่มภาพ +# This refers to the thickness of the line used for free highlighting (not bound to text) +pdfjs-editor-free-highlight-thickness-input = ความหนา +pdfjs-editor-free-highlight-thickness-title = + .title = เปลี่ยนความหนาเมื่อเน้นรายการอื่นๆ ที่ไม่ใช่ข้อความ pdfjs-free-text = .aria-label = ตัวแก้ไขข้อความ pdfjs-free-text-default-content = เริ่มพิมพ์… diff --git a/l10n/uk/viewer.ftl b/l10n/uk/viewer.ftl index 06c665b2c..50dbdfefd 100644 --- a/l10n/uk/viewer.ftl +++ b/l10n/uk/viewer.ftl @@ -288,7 +288,7 @@ pdfjs-text-annotation-type = pdfjs-password-label = Введіть пароль для відкриття цього PDF-файла. pdfjs-password-invalid = Невірний пароль. Спробуйте ще. -pdfjs-password-ok-button = Гаразд +pdfjs-password-ok-button = OK pdfjs-password-cancel-button = Скасувати pdfjs-web-fonts-disabled = Веб-шрифти вимкнено: неможливо використати вбудовані у PDF шрифти.