locked
How to localize/customize autogenerated validation error messages? RRS feed

  • Question

  • User-922763658 posted

    How can I localize or customize autogenerated validation error messages in DynamicData without setting validation attributes for every column (and possible error) in MetaData?
    So, insted of "The field <FieldNameHere> must be a valid Integer.", I would like to see "Kérem csak számot adjon meg a <FieldNameHere> mezőben." (which is "Please insert only numbers for <FNH> field.") for every Integer column.

    Column DisplayNames are already localized so it's kinda funny when it says: "The Műcím field is required." (where Műcím is Title).

    Thank You for helping!

    Wednesday, May 20, 2009 12:03 PM

Answers

  • User1641955678 posted

    One thing you can try is to change the field templates to set the ErrorMessage to what you want on the various validators after the calls to SetUpValidator().

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 20, 2009 8:52 PM

All replies

  • User-1005219520 posted

    This is a localizable string inside Dynamic Data.  If you run the Hungarian version of the framework, that string should be localized.

    Wednesday, May 20, 2009 2:43 PM
  • User-922763658 posted

    Unfortunately I can't replace the .Net framework on the server. Anyway, I don't like the localized version because it's hard to search for the compiler's error messages.
    What about customization or if I have a globalized app?
    I'm using the 4.0 Preview 4, can it help?

    You know hungarian? : )

    Wednesday, May 20, 2009 4:25 PM
  • User-330204900 posted

    If you run the Hungarian version of the framework, that string should be localized.

    Hi Rick, I though with web if the user was using a Hungarian or French browser there should be a way of having the validation error messages appear in there own language (parden me if I completely miss it I18N is relativly new to me), I've been trying to help FTeR via my blog but I was getting nowhere so I  pointed him here [:D]

    Wednesday, May 20, 2009 5:32 PM
  • User-1005219520 posted

    >>You know hungarian? : )

    That was actually David Ebbo's response when I sent him the question. I guess he must know some.

    Steve is right, the client side error messages will be localized by the client user agent (IE, FF, Chrome, etc).

    Wednesday, May 20, 2009 6:01 PM
  • User-922763658 posted

    The browser's preffered language is set to Hungarian (prtscr). I also set EnableScriptGlobalization="True" and EnableScriptLocalization="True", for the script manager.
    Maybe I'm still missing something.

    Wednesday, May 20, 2009 6:24 PM
  • User-1005219520 posted

    David states this should work in the released version - but the preview is not localized. You'll always get English in the previews. Sorry about that - resource constraints.

    Wednesday, May 20, 2009 7:00 PM
  • User-922763658 posted

    Is there no way to overwrite some method or property? It would still be quicker then separately set every column.

    Wednesday, May 20, 2009 7:08 PM
  • User1641955678 posted

    One thing you can try is to change the field templates to set the ErrorMessage to what you want on the various validators after the calls to SetUpValidator().

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 20, 2009 8:52 PM
  • User-922763658 posted

    That is a good idea! Thank You!

    If You don't mind my curiosity, how do you recognized Hungarian? It's not a widely spoken language.

    Thursday, May 21, 2009 5:09 AM
  • User1641955678 posted

    Well, to be honest, I wasn't 100% sure it was Hungarian, so it was a partial guess. Maybe the 'sz' sequence felt Hungarian :)

    David

    Friday, May 22, 2009 1:54 AM
  • User-2146921856 posted

    A think this has not been answered yet. Are the DynamicValidators' strings localizable or we have to wait for ASP.NET 4?

    Thursday, January 7, 2010 8:05 AM
  • User70732873 posted

    Here is my working solution for localizing the required validation error message.

    Modified Text_Edit.ascx.cs Page_load()

    After line:  SetUpValidator(RequiredFieldValidator1);

    Add this one line:

    RequiredFieldValidator1.ErrorMessage=(String.Format(Resources.GlobalResources.ValidationErrorMessageRequiredField,Column.DisplayName));

    Where:

    GlobalResources is my App_GlobalResources file (GlobalResources.resx and GlobalResources.fr-CA.resx in my case). ValidationErrorMessageRequiredField is the resource name inside those files. The french text is as follows:  Le champ {0} est obligatoire. 

     

    Thursday, September 20, 2012 2:45 PM
  • User1434709301 posted

    I recommend using this online tool for localization of any kind: https://poeditor.com/ It's really simple to use and helps you do the job quickly.

    Tuesday, November 5, 2013 8:43 AM