Copied to clipboard

Flag this post as spam?

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


  • mastan 14 posts 73 karma points
    Nov 19, 2014 @ 14:42
    mastan
    0

    Umbraco7 Unobtrusive validation for multiple languages

    Hello All,

    We are trying for unobtrusive validations for multiple languages. But it always gives one language for all countries. Example result mentioned in step 5 which supposed to be two different languages i.e Danish and Swedish. But it always shows Danish language. The process which we have followed mentioned in below. Can someone help us where did we make mistake?

    1.Creating Dictionary files in Umbraco:

    enter image description here

    2.Updating Dictionary Based on Country Wise:

    enter image description here

    3.Updating Dictionary Name

    enter image description here

    4.Updating same name which we have created in Dictionary same name as Updating in Model.

    enter image description here

    5.Result :

    enter image description here

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 19, 2014 @ 15:00
    Jan Skovgaard
    0

    Hi Mastan

    Am I right assuming that the label fields are fetched from the dictionary item as well?

    If so then it's really odd. Could you perhaps show all of the code? What exact version of Umbraco 7 are you using?

    I also assume that there has been setup different hostnames for the sites?

    /Jan

  • mastan 14 posts 73 karma points
    Nov 19, 2014 @ 15:47
    mastan
    0

    Thanks Jan. Here are my comments for your questions.

    1. We use Model to access field names as given in image. If you can share your mail I will send you complete code.

    enter image description here

    2 Umbraco Version 7.1.8

    1. Host name as given in below Image for DK and SE.

    enter image description here

    enter image description here

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 19, 2014 @ 22:33
    Jan Skovgaard
    0

    Hi Mastan

    Ok, the hostnames are setup correctly so must be something in the code.

    Would it be possible if you just share a snippet showing what the code looks like for just the firstname part? It's not that I don't want your e-mail but if you share it here others can see the code as well and come with their input and suggestions, which increases the chances that you'll get the issue solved faster and smarter - Who knows...I might not even be able to figure it out so it's clearly an advantage that more people can see the code.

    /Jan

  • mastan 14 posts 73 karma points
    Nov 21, 2014 @ 13:14
    mastan
    0

    Hi Jan,

    We have ready with complete database and Source code can you please tell me how can i share my code.

    Thanks Mastan

  • mastan 14 posts 73 karma points
    Nov 21, 2014 @ 15:43
    mastan
    0

    HI Jan, Here is our code.

    using System; using System.Collections.Generic;

    using System.ComponentModel.DataAnnotations.Schema;

    using System.ComponentModel.DataAnnotations;

    using System.Web;

    using Umbraco.Web.Mvc;

    using System.ComponentModel;

    using UmbracoValidationAttributes;

    namespace Test.Business.Models { public partial class Registration {

        public int ID { get; set; }
        [UmbracoRequired("Dic_Error_Name")]
        [StringLength(30, MinimumLength = 1)]
        [UmbracoDisplay("Dic_Name")]
        public string Name { get; set; }
        [UmbracoRequired("Dic_Error_Email")]
        [StringLength(30, MinimumLength = 1)]
        [UmbracoDisplay("Dic_Email")]
        public string Email { get; set; }
    }
    

    }

    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]

    public sealed class UmbracoDisplayAttribute : DisplayNameAttribute { public UmbracoDisplayAttribute(string dictionaryKey) : base(dictionaryKey) { }

    public override string DisplayName
    {
        get
        {
            return umbraco.library.GetDictionaryItem(base.DisplayName);
        }
    }
    

    }

    Controller Action:

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using UmbracoTest; using Umbraco.Web.Mvc; using Test.Business.Models;

    namespace UmbracoTest.Controllers { public class TestSurfaceController:SurfaceController {

        public ActionResult NewUser()
        {
            return View();
        }
        [HttpPost]
        public ActionResult NewUser(Registration registration)
        {
            if (ModelState.IsValid)
            {
                return View("NewConfirmation");
            }
            else
            {
                return View();
            }
    
        }
    
        }
    

    }

    View Code:

    @@model ShopUSAMob.Data.Bussiness.Models.user;@ @inherits Umbraco.Web.Mvc.UmbracoViewPage

    <fieldset>
        <legend>user</legend>
    
        @*<h2>@Umbraco.GetDictionaryValue("Dic_NewUser_Heading") </h2>
            <h3>- FÅ POSTADRESSE I USA OG 100 KR. TIL FRAGTEN</h3>*@
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
    
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>
        <p>
            <input type="submit" value="Submit!" />
        </p>
    </fieldset>
    

    }

    Kindly let me know if you want any thing else.

    Thanks Mastan.

  • mastan 14 posts 73 karma points
    Dec 11, 2014 @ 06:34
    mastan
    0

    Hi Jana,

    Can you Please suggest how to work on Unobtrusive validation for multiple languages.

  • mastan 14 posts 73 karma points
    Dec 19, 2014 @ 10:13
    mastan
    0

    Hi Jana, can you please suggest how to work on the unobtrusive validation for multiple languages. We are waiting for your reply

Please Sign in or register to post replies

Write your reply to:

Draft