1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #17115 from calixteman/mv_to_fluent

[api-minor] Move to Fluent for the localization (bug 1858715)
This commit is contained in:
calixteman 2023-10-19 13:40:50 +02:00 committed by GitHub
commit 5d8be99782
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 1311 additions and 28684 deletions

View file

@ -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);

View file

@ -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"
);

View file

@ -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>

View file

@ -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",

View file

@ -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";