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.
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.
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").
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:
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
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
Hi Ismael,
Thank you for responding, however I am using the built in loginModel of Umbraco, so how can I do this?
Regards,
Scott
Scott,
You have lost me is this for umbraco backend login?
Regards
Ismail
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.
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
Just to clarify:
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:
I have the same quesiton. Did you find an answer Scott?
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").
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.
Good idea and done!
is working on a reply...