Copied to clipboard

Flag this post as spam?

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


  • Synergi A/S 3 posts 33 karma points
    Feb 16, 2015 @ 12:36
    Synergi A/S
    0

    Localize Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))

    Is it possible, and how, to localize the default Umbraco loginform ?

    This is based on the default Umbraco Loginform-snippet, but have changed the layout

    @using ClientDependency.Core.Mvc
    @using Umbraco.Web.Controllers
    @using Umbraco.Web.Models
    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @{
        var loginModel = new LoginModel();

        Html.EnableClientValidation();
        Html.EnableUnobtrusiveJavaScript();
        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.min.js");
        Html.RequiresJs("/umbraco_client/Application/JQuery/jquery.validate.unobtrusive.min.js");
       
        dynamic root = CurrentPage.AncestorOrSelf(1);
        loginModel.RedirectUrl = Umbraco.Content(root.myPage).Url;
    }

    @* NOTE: This RenderJsHere code should be put on your main template page where the rest of your script tags are placed *@
    @Html.RenderJsHere()

    @using (Html.BeginUmbracoForm<UmbLoginController>("HandleLogin"))
    {
        <div class="row login-overlay-form">
            <table class="table table-responsive">
                <tr>
                    <td>
                        <img src="/Design/img/shared/47x46_login.png" />
                        <span class="login-title">@library.GetDictionaryItem("Login")</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.TextBoxFor(m => loginModel.Username, null, new { @class = "form-control", @placeholder = library.GetDictionaryItem("UserName") })
                        @Html.ValidationMessageFor(m => loginModel.Username)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.PasswordFor(m => loginModel.Password, new { @class = "form-control", @placeholder = library.GetDictionaryItem("Password") })
                        @Html.ValidationMessageFor(m => loginModel.Password)
                    </td>
                </tr>
                <tr>
                    <td>
                        <button>@library.GetDictionaryItem("Login")</button>
                        <br />@Html.ValidationSummary("loginModel", true)
                        @Html.HiddenFor(m => loginModel.RedirectUrl)
                    </td>
                </tr>
                <tr>
                    <td>
                        <a href="@Umbraco.Content(root.ForgotPassword).Url">@library.GetDictionaryItem("ForgotPassword")</a>
                    </td>
                </tr>
            </table>
        </div>
    }

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 16, 2015 @ 12:42
    Jan Skovgaard
    0

    Hi Synergi

    It should be possible to do that by adding dictionary items for the different parts where it reads @library:GetDictionaryItem("ForgotPassword") for instance. In the settings section you can create a "ForgotPassword" dictionary item in the "Dictionary" folder.

    Is this what you have in mind?

    /Jan

  • Kristoffer Eriksen 185 posts 465 karma points
    Feb 16, 2015 @ 12:46
    Kristoffer Eriksen
    0

    Oh I can see that my quiestion is unclear.

    I've managed to localize the default text, as above, but what I've not been able to localize, is the error-text, when a wrong username and/or password is intered.

    It is the default "Invalid username or password". 

    The same with the validation-messages. Can't figure out how to localize them.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Feb 16, 2015 @ 13:12
    Jan Skovgaard
    0

    Hi Kristoffer

    Why are you posting from 2 accounts? :)

    It seems that the error messages are hardcoded in the controller, and I don't think it's possible to translate/change it unless you're making your own build of the umbraco source code.

    But perhaps you can use a javascript approach and then have the translatble text stored in a data-* attribute.

    Hope this makes sense.

    /Jan

  • Kristoffer Eriksen 185 posts 465 karma points
    Feb 16, 2015 @ 13:15
    Kristoffer Eriksen
    0

    Oh...One account is our Company account, so we can track our quiestions on Our.

    And then when I answer them, I forget to logout out of my own, and use our Company instead :-)

    I will have a look at the data-attribute approach.

    Thank you.

     

Please Sign in or register to post replies

Write your reply to:

Draft