Topics: Localization
Sep 25, 2012 at 4:42 PM

Has anyone got an example of this?

How do I use this in my model within Orchard?  There seems to be no usage examples in 1.4.2...

Much appreciated.

Sep 27, 2012 at 5:33 PM

In Orchard.MVC.DataAnnotation class, there is LocalizedRequired attribute.  How does this work?

How do I decorate my property with this attribute?  Has anyone got any examples?

Oct 5, 2012 at 6:35 AM
Edited Oct 5, 2012 at 6:36 AM

Looking at its usages, it looks like you don't use it explicitly. Instead, just use RequiredAttribute. Orchard adds a custom LocalizedModelValidatorProvider which seems to substitute all RequiredAttribute instances with a LocalizedRequiredAttribute, passing in the original LocalizedRequiredAttribute and a Localizer.

That means the error message that you provide in the RequiredAttributes are localized by default.

Quite nifty if you ask me.

Oct 5, 2012 at 1:30 PM

Thanks sfmskywalker,


Do you have any examples of this implementation?  I have:


[Required(ErrorMessage = "Name is required")]

public string Name { get; set; }


Is this correct?  I am using Vandelay.TranslationManager to look after the translations.  When I generate the .po files, these messages are not picked up as I guess the Orchard command line only picks/reflects any strings preceded by "T" or "@T" (for razor views).


Thanks in advance

Oct 6, 2012 at 5:16 AM

Your example looks fine to me. To provide localized versions of your error messages, you can create .po files. To lear nmore about how that works, please check out the docs. There should be a page about how .po files are created and where you should store them.

Oct 9, 2012 at 1:56 PM

Vandelay.TranslationManager generates .po files for me.   So, what you are suggesting is, that I have to then manually add these to .po files?

Oct 27, 2012 at 6:21 AM

Yes. Unless Vandelay.TranslationManager is able to scan the RequiredAttributes of course.