Skip to content

Commit

Permalink
[api-minor] Move to Fluent for the localization (bug 1858715)
Browse files Browse the repository at this point in the history
- For the generic viewer we use @fluent/dom and @fluent/bundle
- For the builtin pdf viewer in Firefox, we set a localization url
  and then we rely on document.l10n which is a DOMLocalization object.
  • Loading branch information
calixteman committed Oct 18, 2023
1 parent 22d6d95 commit 8bba504
Show file tree
Hide file tree
Showing 150 changed files with 976 additions and 28,665 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -42,7 +42,7 @@
"import/no-mutable-exports": "error",
"import/no-self-import": "error",
"import/no-unresolved": ["error", {
"ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web"]
"ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web", "fluent-bundle", "fluent-dom", ],
}],
"mozilla/avoid-removeChild": "error",
"mozilla/use-includes-instead-of-indexOf": "error",
Expand Down
22 changes: 13 additions & 9 deletions examples/mobile-viewer/viewer.js
Expand Up @@ -97,26 +97,26 @@ const PDFViewerApplication = {
if (exception instanceof pdfjsLib.InvalidPDFException) {
// change error message also for other builds
loadingErrorMessage = l10n.get(
"invalid_file_error",
"pdfjs-invalid-file-error",
null,
"Invalid or corrupted PDF file."
);
} else if (exception instanceof pdfjsLib.MissingPDFException) {
// special message for missing PDFs
loadingErrorMessage = l10n.get(
"missing_file_error",
"pdfjs-missing-file-error",
null,
"Missing PDF file."
);
} else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
loadingErrorMessage = l10n.get(
"unexpected_response_error",
"pdfjs-unexpected-response-error",
null,
"Unexpected server response."
);
} else {
loadingErrorMessage = l10n.get(
"loading_error",
"pdfjs-loading-error",
null,
"An error occurred while loading the PDF."
);
Expand Down Expand Up @@ -234,7 +234,7 @@ const PDFViewerApplication = {
const l10n = this.l10n;
const moreInfoText = [
l10n.get(
"error_version_info",
"pdfjs-error-version-info",
{ version: pdfjsLib.version || "?", build: pdfjsLib.build || "?" },
"PDF.js v{{version}} (build: {{build}})"
),
Expand All @@ -243,20 +243,24 @@ const PDFViewerApplication = {
if (moreInfo) {
moreInfoText.push(
l10n.get(
"error_message",
"pdfjs-error-message",
{ message: moreInfo.message },
"Message: {{message}}"
)
);
if (moreInfo.stack) {
moreInfoText.push(
l10n.get("error_stack", { stack: moreInfo.stack }, "Stack: {{stack}}")
l10n.get(
"pdfjs-error-stack",
{ stack: moreInfo.stack },
"Stack: {{stack}}"
)
);
} else {
if (moreInfo.filename) {
moreInfoText.push(
l10n.get(
"error_file",
"pdfjs-error-file",
{ file: moreInfo.filename },
"File: {{file}}"
)
Expand All @@ -265,7 +269,7 @@ const PDFViewerApplication = {
if (moreInfo.lineNumber) {
moreInfoText.push(
l10n.get(
"error_line",
"pdfjs-error-line",
{ line: moreInfo.lineNumber },
"Line: {{line}}"
)
Expand Down
133 changes: 0 additions & 133 deletions extensions/firefox/tools/l10n.js

This file was deleted.

2 changes: 1 addition & 1 deletion external/importL10n/locales.mjs
Expand Up @@ -70,7 +70,7 @@ function downloadLanguageFiles(root, langCode) {
const MOZ_CENTRAL_PDFJS_DIR = "/raw-file/default/browser/pdfviewer/";

// Defines which files to download for each language.
const files = ["viewer.properties"];
const files = ["viewer.ftl"];
let downloadsLeft = files.length;

const outputDir = path.join(root, langCode);
Expand Down
3 changes: 0 additions & 3 deletions external/webL10n/README.md

This file was deleted.

0 comments on commit 8bba504

Please sign in to comment.