mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
[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.
This commit is contained in:
parent
2a3090224f
commit
66982a2a11
155 changed files with 1311 additions and 28684 deletions
|
@ -240,6 +240,10 @@ class Rasterize {
|
|||
imageResourcesPath,
|
||||
renderForms,
|
||||
};
|
||||
|
||||
// Ensure that the annotationLayer gets translated.
|
||||
document.l10n.connectRoot(div);
|
||||
|
||||
const annotationLayer = new AnnotationLayer({
|
||||
div,
|
||||
annotationCanvasMap: annotationImageMap,
|
||||
|
@ -250,6 +254,15 @@ class Rasterize {
|
|||
await annotationLayer.render(parameters);
|
||||
await annotationLayer.showPopups();
|
||||
|
||||
// With Fluent, the translations are triggered by the MutationObserver
|
||||
// hence the translations could be not finished when we rasterize the div.
|
||||
// So in order to be sure that all translations are done, we wait for
|
||||
// them here.
|
||||
await document.l10n.translateRoots();
|
||||
|
||||
// All translation should be complete here.
|
||||
document.l10n.disconnectRoot(div);
|
||||
|
||||
// Inline SVG images from text annotations.
|
||||
await inlineImages(div);
|
||||
foreignObject.append(div);
|
||||
|
|
|
@ -93,7 +93,11 @@ describe("find bar", () => {
|
|||
await page.waitForSelector(".xfaLayer .highlight");
|
||||
const resultElement = await page.waitForSelector("#findResultsCount");
|
||||
const resultText = await resultElement.evaluate(el => el.textContent);
|
||||
expect(resultText).toEqual("1 of 1 match");
|
||||
/** Unicode bidi isolation characters. */
|
||||
const FSI = "\u2068";
|
||||
const PDI = "\u2069";
|
||||
// Fluent adds these markers to the result text.
|
||||
expect(resultText).toEqual(`${FSI}1${PDI} of ${FSI}1${PDI} match`);
|
||||
const selectedElement = await page.waitForSelector(
|
||||
".highlight.selected"
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@ limitations under the License.
|
|||
<script src="../build/generic/build/pdf.mjs" type="module"></script>
|
||||
<script src="../build/components/pdf_viewer.mjs" type="module"></script>
|
||||
|
||||
<link rel="resource" type="application/l10n" href="../build/generic/web/locale/locale.properties">
|
||||
<link rel="resource" type="application/l10n" href="../build/generic/web/locale/locale.json">
|
||||
</head>
|
||||
<body>
|
||||
<p>Inflight requests: <span id="inflight"></span></p>
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
"pdfjs-web/": "../../web/",
|
||||
"pdfjs-test/": "../",
|
||||
|
||||
"fluent-bundle": "../../node_modules/@fluent/bundle/esm/index.js",
|
||||
"fluent-dom": "../../node_modules/@fluent/dom/esm/index.js",
|
||||
"cached-iterable": "../../node_modules/cached-iterable/src/index.mjs",
|
||||
|
||||
"display-fetch_stream": "../../src/display/fetch_stream.js",
|
||||
"display-l10n_utils": "../../src/display/stubs.js",
|
||||
"display-network": "../../src/display/network.js",
|
||||
|
|
|
@ -33,7 +33,7 @@ var mimeTypes = {
|
|||
".png": "image/png",
|
||||
".log": "text/plain",
|
||||
".bcmap": "application/octet-stream",
|
||||
".properties": "text/plain",
|
||||
".ftl": "text/plain",
|
||||
};
|
||||
|
||||
var defaultMimeType = "application/octet-stream";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue