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

Changes to allow localisation/overwriting strings #15

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

jamiehumphries
Copy link

…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.
@jamiehumphries jamiehumphries changed the title Localisation Changes to allow localisation/overwriting strings Jan 26, 2024
Copy link

@DanCorderSoftwire DanCorderSoftwire left a 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;

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.

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.

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.

Copy link
Collaborator

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/GovUkHtmlHelperExtensions.cs Outdated Show resolved Hide resolved
@@ -38,7 +38,7 @@ public static class ErrorSummaryHtmlGenerator
{
Title = new ErrorSummaryTitle
{
Text = "There is a problem"
Text = errorSummaryTitle

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
@Glenn-Clarke Glenn-Clarke requested a review from jdgage April 9, 2024 15:26
public string ErrorMessageIfMissing { get; private set; }
public virtual string ErrorMessageIfMissing { get; }

public virtual string IsWholeNumberErrorMessage => "";

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.

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

Successfully merging this pull request may close these issues.

4 participants