Closed tomasr78 closed 9 years ago
Not sure if this is it but you have [Display(Name...
instead of [DisplayName(...
This makes no difference. Could you confirm that this is correct format to translate formatted strings using ((())) and %?
[Display(Name = "[[[User name]]]")] [Required(ErrorMessage = "[[[The %0 field is required.|||(((User name)))]]]")] public string UserName { get; set; }
I have created a simple demo which demonstrate the issue. If you run the project, go to http://localhost:1892/lt/Account/Login and click login leaving both fields empty you will get error message "Laukas (((User name))) yra privalomas." The %0 replaced by (((User name))) but (((User name))) never with actually translation.
VS 2012 MVC Demo project http://we.tl/MWOCec3525
It seems to work okay for me. Here's what I've got:
Property in a ViewModel:
[Required(ErrorMessage="[[[%0 Please fill in this field|||(((Your Email Address)))]]]")]
[Email(ErrorMessage = "[[[Not a valid email address]]]")]
[System.Web.Mvc.Remote("ValidateEmail", "Account")]
[Display(Name="[[[Your Email Address]]]")]
public string Email { get; set; }
locale\fr-CA\message.po:
#: Models\AccountModels.cs:170
msgid "Your Email Address"
msgstr "Your Email Address (fr-CA)"
When language set to fr-CA, the data val required is output as:
"Your Email Address (fr-CA) Please fill in this field"
When language set to another, then it is output as:
"Your Email Address Please fill in this field"
Please confirm you have a translation for your [[[User name]]] nugget in your .PO file; better still that it is being translated when used elsewhere e.g. from HTML.
I just updated project with NuGet version 2.1.1 which you uploaded yesterday and problem gone, it seems I have used 2.x old version. Good work! First day on NuGet and already 4000 downloads.
Right you are, I'm pleased it works now, thanks for the update.
In i18n description there is example which shows how to translate attributes descriptions with parameters.
I have tried to implement the same in my code
[Display(Name = "[[[E-mail]]]")] [Required(ErrorMessage = "[[[The %0 field is required.|||(((E-mail)))]]]")][DataType(DataType.EmailAddress)] public string Email { get; set; }
and HTML result which MVC is produce is below
data-val-required="The (((E-mail))) field is required."
The (((E-mail))) is not replaced with translation.
This is the only issue which I have with i18n, everything else working perfectly.