Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 macro options to configure CharacterCount translations #2895
Add macro options to configure CharacterCount translations #2895
Changes from all commits
7a4d712
d7993a0
e3a889e
d88f1fa
75d6527
5a01101
cd41407
7fac761
c79ea2a
c16fa49
ee5882d
db8a51f
1376462
cd15d29
bfccd7e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super quick not-even-tried-it example, but how about a function that does all i18n attributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is appealing, and we don't really need to introduce a separate
i18n
namespace for them, we can just pick the values fromparams
directly as we do have to read them manually (unless someone knows of some black magic to go kebab-case to cameCase or the other way around with Nunjucks without adding a filter).There's a little trickiness to it as translations can be strings or object, depending of if they're pluralised or not. Using the current helper, the template makes it clear which attribute expects which, so we'd need to devise an API that lets us do the same, maybe:
That said, I think there's ground for a codebase wise look at some abstraction around data attributes, like a
govukDataAttributes
helper on a similar model, as setting them is always the same thing:data-{{name}}={{value}}
(sometimes escaped)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an issue to track: #2917 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romaricpascal Yeah, look less at the "how" and more of a nice neat way to generate attributes
We already have this syntax elsewhere for
.attributes
:Then other "ad-hoc" data attributes in places:
If each template had a map (or object) of all its available attributes, defaults, parameter overrides etc, you could write both regular and data attributes into the template in a nice unit-testable way
This certainly isn't a blocker, just an opportunity to makes the template look neater