Skip to content

Commit 66982a2

Browse files
committed
[api-minor] Move to Fluent for the localization (bug 1858715)
- 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.
1 parent 2a30902 commit 66982a2

File tree

155 files changed

+1318
-28691
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1318
-28691
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"import/no-mutable-exports": "error",
4343
"import/no-self-import": "error",
4444
"import/no-unresolved": ["error", {
45-
"ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web"]
45+
"ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web", "fluent-bundle", "fluent-dom"],
4646
}],
4747
"mozilla/avoid-removeChild": "error",
4848
"mozilla/use-includes-instead-of-indexOf": "error",

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*.css text eol=lf
55
*.html text eol=lf
66
*.md text eol=lf
7-
*.properties text eol=lf
7+
*.ftl text eol=lf
88
*.yml text eol=lf
99
*.json text eol=lf
1010
*.config text eol=lf

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
l10n/en-US/*.properties @mozilla/pdfjs-l10n
1+
l10n/en-US/*.ftl @mozilla/pdfjs-l10n

examples/mobile-viewer/viewer.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,26 @@ const PDFViewerApplication = {
9797
if (exception instanceof pdfjsLib.InvalidPDFException) {
9898
// change error message also for other builds
9999
loadingErrorMessage = l10n.get(
100-
"invalid_file_error",
100+
"pdfjs-invalid-file-error",
101101
null,
102102
"Invalid or corrupted PDF file."
103103
);
104104
} else if (exception instanceof pdfjsLib.MissingPDFException) {
105105
// special message for missing PDFs
106106
loadingErrorMessage = l10n.get(
107-
"missing_file_error",
107+
"pdfjs-missing-file-error",
108108
null,
109109
"Missing PDF file."
110110
);
111111
} else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
112112
loadingErrorMessage = l10n.get(
113-
"unexpected_response_error",
113+
"pdfjs-unexpected-response-error",
114114
null,
115115
"Unexpected server response."
116116
);
117117
} else {
118118
loadingErrorMessage = l10n.get(
119-
"loading_error",
119+
"pdfjs-loading-error",
120120
null,
121121
"An error occurred while loading the PDF."
122122
);
@@ -234,40 +234,44 @@ const PDFViewerApplication = {
234234
const l10n = this.l10n;
235235
const moreInfoText = [
236236
l10n.get(
237-
"error_version_info",
237+
"pdfjs-error-version-info",
238238
{ version: pdfjsLib.version || "?", build: pdfjsLib.build || "?" },
239-
"PDF.js v{{version}} (build: {{build}})"
239+
"PDF.js v{ $version } (build: { $build })"
240240
),
241241
];
242242

243243
if (moreInfo) {
244244
moreInfoText.push(
245245
l10n.get(
246-
"error_message",
246+
"pdfjs-error-message",
247247
{ message: moreInfo.message },
248-
"Message: {{message}}"
248+
"Message: { $message }"
249249
)
250250
);
251251
if (moreInfo.stack) {
252252
moreInfoText.push(
253-
l10n.get("error_stack", { stack: moreInfo.stack }, "Stack: {{stack}}")
253+
l10n.get(
254+
"pdfjs-error-stack",
255+
{ stack: moreInfo.stack },
256+
"Stack: { $stack }"
257+
)
254258
);
255259
} else {
256260
if (moreInfo.filename) {
257261
moreInfoText.push(
258262
l10n.get(
259-
"error_file",
263+
"pdfjs-error-file",
260264
{ file: moreInfo.filename },
261-
"File: {{file}}"
265+
"File: { $file }"
262266
)
263267
);
264268
}
265269
if (moreInfo.lineNumber) {
266270
moreInfoText.push(
267271
l10n.get(
268-
"error_line",
272+
"pdfjs-error-line",
269273
{ line: moreInfo.lineNumber },
270-
"Line: {{line}}"
274+
"Line: { $line }"
271275
)
272276
);
273277
}

extensions/firefox/tools/l10n.js

Lines changed: 0 additions & 133 deletions
This file was deleted.

external/importL10n/locales.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function downloadLanguageFiles(root, langCode) {
7070
const MOZ_CENTRAL_PDFJS_DIR = "/raw-file/default/browser/pdfviewer/";
7171

7272
// Defines which files to download for each language.
73-
const files = ["viewer.properties"];
73+
const files = ["viewer.ftl"];
7474
let downloadsLeft = files.length;
7575

7676
const outputDir = path.join(root, langCode);

external/webL10n/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)