diff --git a/Yavsc/Attributes/Validation/RequiredAttribute.cs b/Yavsc/Attributes/Validation/RequiredAttribute.cs index 2ae3adc4..474feed5 100644 --- a/Yavsc/Attributes/Validation/RequiredAttribute.cs +++ b/Yavsc/Attributes/Validation/RequiredAttribute.cs @@ -1,4 +1,5 @@ using System; +using System.Resources; namespace Yavsc.Attributes.Validation { @@ -50,9 +51,11 @@ namespace Yavsc.Attributes.Validation { this.ErrorMessage = pattern; } + + public override string FormatErrorMessage(string name) { - return Startup.GlobalLocalizer[name]; + return Startup.GlobalLocalizer[this.ErrorMessageResourceName]; } } } \ No newline at end of file diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resources b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resources new file mode 100644 index 00000000..31e1440c Binary files /dev/null and b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resources differ diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx index 91d34787..a8e17195 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.en.resx @@ -346,5 +346,9 @@ contact a performer Passwords must have at least one non letter and non digit character. Passwords must have at least one digit ('0'-'9'). Passwords must have at least one uppercase ('A'-'Z'). - + Passwords and confirmation are not the same. +Password confirmation + Invalid user name. +Valid caracters are: underscore '_', '-', 'a' - 'z', 'A' - 'Z', '0' - '9', the space and the dot. + diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resources b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resources new file mode 100644 index 00000000..1b01e4bc Binary files /dev/null and b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resources differ diff --git a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx index 3fcddb02..9c2545ce 100644 --- a/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx +++ b/Yavsc/Resources/Yavsc.Resources.YavscLocalisation.fr.resx @@ -437,7 +437,7 @@ Supprimer mon profil professionel Français Anglais - Nom d'utilisateur invalide. + Nom d'utilisateur invalide. Les valides sont: le souligné '_', le titret '-', de 'a' à 'z', de 'A' à 'Z', de 0 à 9, l'espace et le point. Ce champ est obligatoire. Champ invalide ... @@ -445,5 +445,8 @@ Mot de passe doit contenir au moins a caractère spécial (ni un chiffre, ni une lettre). Les mots de passe doivent contenir au moins un chiffre ('0' à '9'). Les mots de passe doivent contenir au moins une lettre majuscule ('A' à 'Z'). + Le mot de passe et sa confirmation ne sont pas les mêmes. + Confirmation du mot de passe + diff --git a/Yavsc/Resources/YavscLocalisation.cs b/Yavsc/Resources/YavscLocalisation.cs index 9404f46c..59c37353 100644 --- a/Yavsc/Resources/YavscLocalisation.cs +++ b/Yavsc/Resources/YavscLocalisation.cs @@ -1,10 +1,33 @@ +using System.IO; +using System.Reflection; +using System.Resources; + namespace Yavsc.Resources { /// /// Makes possible the code injection /// - public class YavscLocalisation + public class YavscLocalisation : ResourceSet { + public YavscLocalisation(string path) : base(path) + { + } + public YavscLocalisation(Stream stream) : base(stream) + { + } + public static string PassAndConfirmDontMach + { + get + { + return Startup.GlobalLocalizer["PassAndConfirmDontMach"]; + } + } + public static string UserName { get { return Startup.GlobalLocalizer["UserName"]; } } + public static string Password { get { return Startup.GlobalLocalizer["Password"]; } } + public static string PasswordConfirm { get { return Startup.GlobalLocalizer["PasswordConfirm"]; } } + + + } } diff --git a/Yavsc/ViewModels/Account/RegisterViewModel.cs b/Yavsc/ViewModels/Account/RegisterViewModel.cs index a5cfdad6..f47145d3 100644 --- a/Yavsc/ViewModels/Account/RegisterViewModel.cs +++ b/Yavsc/ViewModels/Account/RegisterViewModel.cs @@ -8,27 +8,27 @@ namespace Yavsc.ViewModels.Account // ErrorMessage = "", - [Display(Name = "Nom d'utilisateur")] + [Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "UserName")] [StringLength(102)] - [YaRegularExpression(@"[a-zA-Z0-9 ._-]+", - ErrorMessage = "Caratères autorisés: lettres, chiffres, espace point tiret et souligné.")] + [YaRegularExpression(@"[a-zA-Z0-9 ._-]+", ErrorMessageResourceName="InvalidUserName", ErrorMessageResourceType = typeof(Yavsc.Resources.YavscLocalisation))] public string UserName { get; set; } - [YaRequired("Ce champ est requis.")] + [YaRequired()] // [EmailAddress] [Display(Name = "Email")] public string Email { get; set; } - [YaRequired(ErrorMessage="Spécifiez un mot de passe.")] - // [StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {1} caractères.", MinimumLength = 6)] - [DataType(DataType.Password, - ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")] + [StringLength(100, MinimumLength = 6)] + [DataType(DataType.Password)] + + // ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")] - [Display(Name = "Mot de passe")] + [Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "Password")] public string Password { get; set; } - [Display(Name = "Confirmer le mot de passe")] - [Compare("Password", ErrorMessage = "Le mot de passe et sa confirmation ne sont pas les mêmes.")] + [DataType(DataType.Password)] + [Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "PasswordConfirm")] + [Compare("Password", ErrorMessageResourceName = "PassAndConfirmDontMach", ErrorMessageResourceType = typeof(Yavsc.Resources.YavscLocalisation) )] public string ConfirmPassword { get; set; } public string GoogleRegId { get; set; } diff --git a/Yavsc/Views/Home/Index.cshtml b/Yavsc/Views/Home/Index.cshtml index 7ded8216..4d9070fc 100755 --- a/Yavsc/Views/Home/Index.cshtml +++ b/Yavsc/Views/Home/Index.cshtml @@ -85,6 +85,7 @@ } + } @section ctxmenu {