Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for translating multiple tag attributes #2381

Open
2 tasks done
dannycolin opened this issue Jun 22, 2022 · 0 comments
Open
2 tasks done

Add support for translating multiple tag attributes #2381

dannycolin opened this issue Jun 22, 2022 · 0 comments
Assignees
Labels
bug Something is broken! Component: l10n Issues with translations

Comments

@dannycolin
Copy link
Collaborator

Before submitting a bug report

  • I updated to the latest version of Multi-Account Container and tested if I can reproduce the issue
  • I searched for existing reports to see if it hasn't already been reported

Step to reproduce

N/A

Actual behavior

The current code in js/i18n.js doesn't let us specify an attribute.

Expected behavior

We should be able to translate attributes. Code example:

  document.querySelectorAll('[data-i18n]').forEach(node => {
    let [attr, text] = node.dataset.i18n.split('|');
    text = browser.i18n.getMessage(text);
    attr ? node.setAttribute(attr, text) : node.append(text);
  });
  <input data-i18n="placeholder|Here the text for my placeholder">

To support multiple attributes, we simply split the string twice and use two different delimiter. For example,

<input data-i18n="placeholder:My Placeholder|title:My Title">

Additional informations

No response

Provide a copy of Troubleshooting Information page

N/A
@dannycolin dannycolin added bug Something is broken! Component: l10n Issues with translations labels Jun 22, 2022
@dannycolin dannycolin self-assigned this Jun 22, 2022
@dannycolin dannycolin changed the title Add support for translating tag attributes (e.g. placeholder) Add support for translating multiple tag attributes Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken! Component: l10n Issues with translations
Projects
None yet
Development

No branches or pull requests

1 participant