Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Scott Hugh Alexandar Petersen 87 posts 237 karma points
    Jul 24, 2014 @ 12:53
    Scott Hugh Alexandar Petersen
    0

    Localized/custom error messages/validationsummary

    Hi,

    I am using the built in loginmodel to log in people on a Danish site, however the error messages are mixed Danish/English and the validationsummary error message is all English, does anyone know how to solve this?

    I have set culture/hostname to Danish instead of inherit and in the web.config default language to da.

    Regards

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Jul 24, 2014 @ 15:59
    Ismail Mayat
    0

    Scott,

    Take a look at http://creativewebspecialist.co.uk/2014/04/17/umbraco-mvc-regionalisation-of-error-messages/ you need to decorate your models with these attributes so that it then picks up the error messages from the umbraco dictionary.

    Regards

    Ismail

  • Scott Hugh Alexandar Petersen 87 posts 237 karma points
    Jul 24, 2014 @ 19:53
    Scott Hugh Alexandar Petersen
    0

    Hi Ismael,

    Thank you for responding, however I am using the built in loginModel of Umbraco, so how can I do this?

    Regards,

    Scott

  • Ismail Mayat 4511 posts 10062 karma points MVP 2x admin c-trib
    Jul 25, 2014 @ 11:52
    Ismail Mayat
    0

    Scott,

    You have lost me is this for umbraco backend login?

    Regards

    Ismail

  • Scott Hugh Alexandar Petersen 87 posts 237 karma points
    Jul 25, 2014 @ 12:37
    Scott Hugh Alexandar Petersen
    0

    Hi Ismail,

    I am doing a login boks on the frontend of a website, to do this I have used the standard example of the login form in the developer section of Umbraco.

    var loginModel = new LoginModel();
    using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
    {
        <fieldset id="mLoginForm">
    
            @Html.ValidationSummary("loginModel", true)
    
            @Html.LabelFor(m => loginModel.Username, "Bruger:")
            @Html.TextBoxFor(m => loginModel.Username, new { placeholder = "Bruger"})
            @Html.ValidationMessageFor(m => loginModel.Username, "Feltet Bruger skal udfyldes.")
            <br />
    
            @Html.LabelFor(m => loginModel.Password, "Kode:")
            @Html.PasswordFor(m => loginModel.Password, new { placeholder = "Kode" })
            @Html.ValidationMessageFor(m => loginModel.Password, "Feltet Kode skal udfyldes.")
            <br />
    
            <button class="pull-right">Log ind</button>
        </fieldset>  
    }
    

    But the validationsummary is in english and not in danish which is not the best way of presenting an error to the user.

    Thanks Ismail

  • Scott Hugh Alexandar Petersen 87 posts 237 karma points
    Jul 25, 2014 @ 12:49
    Scott Hugh Alexandar Petersen
    0

    Just to clarify:

    This is the login box

    This is the login box

    When I click log ind, then if it is wrong creds it will give an error, but in English, not in Danish.

    This is the validation summary error:

    Validation summary

  • Maria 34 posts 128 karma points
    Sep 15, 2015 @ 06:37
    Maria
    0

    I have the same quesiton. Did you find an answer Scott?

  • Maria 34 posts 128 karma points
    Sep 15, 2015 @ 06:49
    Maria
    0

    I actually found an answer myself :D

    Instead of @Html.ValidationSummary("loginModel", true) write @Html.ValidationSummary(true, "your custom validation message here")

    You can also use a dictionary item instead of the string if you have a multilanguage site.

    The solution of course only works if you have a single validaiton message (like "Login failed") and not a message for each field ("incorrect email" and "incorrect password").

  • Barry Fogarty 493 posts 1129 karma points
    Sep 15, 2015 @ 08:32
    Barry Fogarty
    1

    Alternatively, and if you need individual localised validation messages, you can copy the loginModel class from the Umbraco source into your own project and reference this model in your view. Then you can follow the instructions Ismail linked to above to use the dictionary.

    I have raised an issue on the tracker to localise the validation message strings in the core:

    http://issues.umbraco.org/issue/U4-7102

    Please upvote if you would like to see this feature in the core.

  • Maria 34 posts 128 karma points
    Sep 15, 2015 @ 08:43
    Maria
    0

    Good idea and done!

Please Sign in or register to post replies

Write your reply to:

Draft