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 ability to pass translation strings into accordion component via JS #2802

Closed
5 tasks done
Tracked by #1708
vanitabarrett opened this issue Aug 22, 2022 · 0 comments · Fixed by #2826
Closed
5 tasks done
Tracked by #1708

Add ability to pass translation strings into accordion component via JS #2802

vanitabarrett opened this issue Aug 22, 2022 · 0 comments · Fixed by #2826
Assignees
Milestone

Comments

@vanitabarrett
Copy link
Contributor

vanitabarrett commented Aug 22, 2022

What

Add ability for users to pass a translation object in via JavaScript (at the point of initialisation). This is an alternative method to passing translation strings via the Nunjucks macros (data-attributes).

Example:

new Accordion($element, {

  "i18n.showAllSections": "Show everything"

}).init()

Why

Some users may prefer to pass translation strings via JavaScript, or it may be better suited to their service.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • It’s possible to provide translations to the accordion component via JavaScript
  • Expanded logic which looks up translations passed via data attributes, to lookup translations provided by JavaScript
  • Data attribute translations take priority over JS translations, if both provided
  • The accordion component still works if no/only some translations are passed (falls back to defaults)
  • The accordion component has tests which cover the ability to translate via JavaScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3 participants