mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
[Editor] Utilize Fluent "better" when localizing the AltText
Currently we manually localize and update the DOM-elements of the AltText-button, and it seems nicer to utilize Fluent "properly" for that task. This can be achieved by introducing an explicit `span`-element on the AltText-button (similar to e.g. the regular toolbar-buttons), and adding a few more l10n-strings, since that allows just setting the `data-l10n-id`-attribute on all the relevant DOM-elements. Finally, note how we no longer need to localize any strings eagerly when initializing the various editors.
This commit is contained in:
parent
9108848743
commit
ee812b5df2
4 changed files with 70 additions and 58 deletions
|
@ -94,6 +94,14 @@ const copyImage = async (page, imagePath, number) => {
|
|||
await waitForImage(page, getEditorSelector(number));
|
||||
};
|
||||
|
||||
async function waitForTranslation(page) {
|
||||
return page.evaluate(async () => {
|
||||
await new Promise(resolve => {
|
||||
window.requestAnimationFrame(resolve);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const switchToStamp = switchToEditor.bind(null, "Stamp");
|
||||
|
||||
describe("Stamp Editor", () => {
|
||||
|
@ -987,6 +995,7 @@ describe("Stamp Editor", () => {
|
|||
const buttonSelector = `${editorSelector} button.altText.new`;
|
||||
await page.waitForSelector(buttonSelector, { visible: true });
|
||||
|
||||
await waitForTranslation(page);
|
||||
// Check the text in the button.
|
||||
let text = await page.evaluate(
|
||||
sel => document.querySelector(sel).textContent,
|
||||
|
@ -1036,6 +1045,7 @@ describe("Stamp Editor", () => {
|
|||
await waitForSelectedEditor(page, editorSelector);
|
||||
await page.waitForSelector(buttonSelector, { visible: true });
|
||||
|
||||
await waitForTranslation(page);
|
||||
// Check the text in the button.
|
||||
text = await page.evaluate(
|
||||
sel => document.querySelector(sel).textContent,
|
||||
|
@ -1078,6 +1088,7 @@ describe("Stamp Editor", () => {
|
|||
await page.click("#newAltTextSave");
|
||||
await page.waitForSelector("#newAltTextDialog", { visible: false });
|
||||
|
||||
await waitForTranslation(page);
|
||||
// Check the text in the button.
|
||||
text = await page.evaluate(
|
||||
sel => document.querySelector(sel).firstChild.textContent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue