-
Notifications
You must be signed in to change notification settings - Fork 334
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 character count component via data-attributes #2701
Comments
As the component is relying on pluralisation, should it also receive a locale through data attributes to decide on which plural form to use? Was there any discussion around the shape for that attribute? Translations are passed as |
I think mixing them in together is probably fine. We already have Probably need to check with @querkmachine to see how intentional it is, but a lot of the design decisions we've made so far have mimicked i18next – including the fact that replacements can be mixed in with options (see https://www.i18next.com/translation-function/essentials#overview-options), although for us it's the only way to pass them at the minute. (As touched on in #2804 (comment), an alternative approach would be to use the |
Ended up having a separate 'i18nLocale' option that falls back to 'lang' on the JavaScript side. Was there ever a discussion on passing the locale to the Nunjucks template or are we just expecting users to set |
I would expect in the vast majority of cases, the correct implementation would have the character count inside a parent element that has the lang attribute – potentially on the I think adding a top-level On that basis, and given it can be set using the |
Good point of avoiding to encourage people of always setting a I couldn't find any occurences of something like If we wanted to be super clean in naming, which I'd be keen on, I'd like to move to having We could start with:
I guess 2 and 3 are a little like the updates to the character count attributes and could be done in 5.x for the final swap happening in 6.x if we're happy with the |
@romaricpascal I agree that the inconsistent use of the I'd suggest opening a new issue to resolve the |
If we're happy with letting the consuming code wrap, that's fine by me as well 😄 Created #2893 to track the |
Reopening as the macro PR is still open |
Re-opened as I think we still need a full page translated example for it. There's a non-hidden test example for it. If that's enough, we can close this issue, I think. |
What
Add the ability to pass translation strings into the character count component, using the Nunjucks macro.
The logic to lookup translation strings in data attributes and get them in a JS object format should already have been covered by #2699 , so this should just be a case of adding the Nunjucks macro options to the component and any changes to the component JS to switch out the hardcoded strings.
Why
So user can translate the hardcoded strings in our character count component.
Passing translations via the Nunjucks macro enables them to do this without having to understand where different strings are (e.g: Nunjucks vs JavaScript) as it’s the same interface for both.
Who needs to work on this
Developers
Who needs to review this
Developers
Done when
The text was updated successfully, but these errors were encountered: