Html.LabelFor does not kick localization

Topics: Localization, Writing modules
Mar 23, 2015 at 11:34 AM
Hi there,

First thing first, I know that LabelFor in Orchard (I'm talking about 1.7.3 here) has an overload where we can pass a LocalizaedString, but what I am trying to do is to use the localized DisplayName attribute and it seems to not be working.

I can see that Orchard has a LocalizedModelValidatorProvider which takes care of localizing most of the validation attributes. In that case, I can also see that the DisplayName attribute of the model is localized, which helps in generating the error messages inthe format "The {0} field is required".

What I noticed is that the Html.LabelFor helper does not go through any localization at all, which means that I have to replicate the string in the view too other than on the ViewModel.

Does anyone know if there is a quick way to avoid this? Does the new version have somthing like a localized ModelMetadataProvider that takes care of all the attributes and not just the Validation?