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

Decide prioritisation order for methods of passing in translation strings #2781

Closed
3 tasks done
Tracked by #1708
vanitabarrett opened this issue Aug 16, 2022 · 4 comments
Closed
3 tasks done
Tracked by #1708

Comments

@vanitabarrett
Copy link
Contributor

vanitabarrett commented Aug 16, 2022

What

Decide the priority order if all are provided by the user:

  • translation strings via JavaScript
  • translation strings via data attributes

Why

We want to implement two ways of passing translation strings to component JS. We need to know how to handle a situation where a user uses both methods.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

@domoscargin
Copy link
Contributor

domoscargin commented Aug 17, 2022

The only wrinkle here for me is that we have two different JS initialisation scenarios:

  1. It gets initialised via initAll
  2. It gets initialised for an individual component

data attributes should definitely take precedence over [1], but [2] is potentially a bit trickier. I guess the deciding factor is that we want to favour data attributes in the Design System to avoid getting too technical.

tldr: data-attributes > JavaScript initialisation

@querkmachine
Copy link
Member

I don't think we currently have any way of telling whether a JS config option has come from initAll or from an individual initialisation; and I'm not sure how simple it would be to give one of those methods priority over the other—as whichever runs first will be the one to configure the component (barring the current issues around multiple initialisations).

Creating and documenting that complexity is probably not in our interest or useful to users, so I'm in support of data-* attributes always trumping JS configuration.

@36degrees
Copy link
Contributor

All makes sense to me.

I also don't think we have any way at the minute to tell whether a component was initialised by initAll or individually, and don't think we have a use case where it's important at the minute.

@domoscargin
Copy link
Contributor

OK, it looks like we're all agreed:

config passed by data attributes always trumps config passed by JavaScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

4 participants