-
Notifications
You must be signed in to change notification settings - Fork 2
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
Changes to allow localisation/overwriting strings #15
base: master
Are you sure you want to change the base?
Conversation
…ute description as secondary source of label.
… with resources from a specified assembly, allowing for localisation. Original functionality should be preserved for English.
…overwritten to allow for localisation. Current functionality and strings for English are preserved.
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.
I think this will work, but there are a number of things I'd ideally like to be changed.
Leaving for Jamie to decide on whether these things should be fixed given the time constraints.
public string ErrorMessageIfMissing | ||
{ | ||
get => GetResourceValue(_errorMessageIfMissing); | ||
private set => _errorMessageIfMissing = value; |
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.
As a general thing, having a property that returns a different value to what is set makes me extremely uncomfortable. You could just set the private variable in the constructor instead.
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.
Actually, does this rely on the base class behaviour of returning the resource key if it's not found to pass through errorMessageIfMissing
if it's actually some text?
I think this either needs explicitly named fields for each or much clearer naming of the existing shared field.
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.
Hmm, the more I look at this, the more I think it would make sense to just create a new GovUkDataBindingLocalisableMandatoryDecimalErrorTextAttribute
in parallel to this one.
It would mean a large, but straightforward search and replace in the SEA codebase but I think it would be much clearer.
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.
I think I've managed to do this separation, but would like some feedback on how I've implemented it. It's actually a smaller change in SEA as these are only used in a few places.
GovUkDesignSystem/Attributes/DataBinding/GovUkDataBindingMandatoryDecimalErrorTextAttribute.cs
Outdated
Show resolved
Hide resolved
GovUkDesignSystem/Attributes/GovUkRadioCheckboxLabelTextAttribute.cs
Outdated
Show resolved
Hide resolved
GovUkDesignSystem/GovUkDesignSystemComponents/FooterViewModel.cs
Outdated
Show resolved
Hide resolved
@@ -38,7 +38,7 @@ public static class ErrorSummaryHtmlGenerator | |||
{ | |||
Title = new ErrorSummaryTitle | |||
{ | |||
Text = "There is a problem" | |||
Text = errorSummaryTitle |
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.
Arguably the translation for this (and things like the copyright notice) should actually be part of this library. However it doesn't seem worth the effort right now for this minimal amount of text.
…helper extension arguments.Radio checkbox using Single instead of First. Simplified footer property names.
…eby "Display" attributes can be used in addition to the custom GovDesignLibrary attributes when defining which label to show for radio buttons and checkboxes
public string ErrorMessageIfMissing { get; private set; } | ||
public virtual string ErrorMessageIfMissing { get; } | ||
|
||
public virtual string IsWholeNumberErrorMessage => ""; |
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.
I'm not keen on adding these properties to these classes that will never use them, but I don't think it's worth the effort to change it at the moment.
I'm not sure exactly what I'd do differently to simplify things, but perhaps the model binder could look for two different attribute types. I might even go further and create two different model binders (one localisable) with a shared base.
Resubmission of #16 Changes to allow localisation/overwriting strings
Relates to PC-599 for beis-simple-energy-advice-beta.