Localisation
This commit is contained in:
parent
41d803f851
commit
757c5ca2ea
23 changed files with 26 additions and 39 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
using Yavsc.Resources;
|
|
||||||
|
|
||||||
namespace Yavsc.Attributes.Validation
|
namespace Yavsc.Attributes.Validation
|
||||||
{
|
{
|
||||||
|
|
@ -11,7 +10,7 @@ namespace Yavsc.Attributes.Validation
|
||||||
|
|
||||||
public override string FormatErrorMessage(string name)
|
public override string FormatErrorMessage(string name)
|
||||||
{
|
{
|
||||||
return ResourcesHelpers.DefaultResourceManager.GetString(this.ErrorMessageResourceName);
|
return ResourcesHelpers.GlobalLocalizer[this.ErrorMessageResourceName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Yavsc.Attributes.Validation
|
||||||
}
|
}
|
||||||
public YaRequiredAttribute ()
|
public YaRequiredAttribute ()
|
||||||
{
|
{
|
||||||
this.ErrorMessage = ResourcesHelpers.DefaultResourceManager.GetString("RequiredField");
|
this.ErrorMessage = ResourcesHelpers.GlobalLocalizer["RequiredField"];
|
||||||
|
|
||||||
}
|
}
|
||||||
public override bool IsValid(object value) {
|
public override bool IsValid(object value) {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace Yavsc.Attributes.Validation
|
||||||
private long maxLen;
|
private long maxLen;
|
||||||
public YaStringLength(long maxLen) : base(
|
public YaStringLength(long maxLen) : base(
|
||||||
()=>string.Format(
|
()=>string.Format(
|
||||||
ResourcesHelpers.DefaultResourceManager.GetString("BadStringLength"),
|
ResourcesHelpers.GlobalLocalizer["BadStringLength"],
|
||||||
maxLen))
|
maxLen))
|
||||||
{
|
{
|
||||||
this.maxLen = maxLen;
|
this.maxLen = maxLen;
|
||||||
|
|
@ -43,12 +43,12 @@ namespace Yavsc.Attributes.Validation
|
||||||
if (MinLen<0) {
|
if (MinLen<0) {
|
||||||
// DetailledMaxStringLength
|
// DetailledMaxStringLength
|
||||||
return string.Format(
|
return string.Format(
|
||||||
ResourcesHelpers.DefaultResourceManager.GetString("DetailledMaxStringLength"),
|
ResourcesHelpers.GlobalLocalizer["DetailledMaxStringLength"],
|
||||||
maxLen,
|
maxLen,
|
||||||
excedent);
|
excedent);
|
||||||
} else
|
} else
|
||||||
return string.Format(
|
return string.Format(
|
||||||
ResourcesHelpers.DefaultResourceManager.GetString("DetailledMinMaxStringLength"),
|
ResourcesHelpers.GlobalLocalizer["DetailledMinMaxStringLength"],
|
||||||
MinLen,
|
MinLen,
|
||||||
maxLen,
|
maxLen,
|
||||||
manquant,
|
manquant,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace Yavsc.Attributes.Validation
|
||||||
{
|
{
|
||||||
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
|
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
|
||||||
{
|
{
|
||||||
public YaValidationAttribute() : base(()=> ResourcesHelpers.DefaultResourceManager.GetString("validationError"))
|
public YaValidationAttribute() : base(()=> ResourcesHelpers.GlobalLocalizer["validationError"])
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Yavsc.Attributes.Validation
|
||||||
|
|
||||||
public override string FormatErrorMessage(string name)
|
public override string FormatErrorMessage(string name)
|
||||||
{
|
{
|
||||||
return ResourcesHelpers.DefaultResourceManager.GetString(name);
|
return ResourcesHelpers.GlobalLocalizer[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,8 @@
|
||||||
|
using System;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
using Yavsc.Resources;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
public static class ResourcesHelpers {
|
public static class ResourcesHelpers {
|
||||||
|
public static IStringLocalizer GlobalLocalizer = null ;
|
||||||
static ResourceManager _defaultResourceManager
|
|
||||||
= ResourceManager.CreateFileBasedResourceManager("Yavsc.Localization",".",typeof(YavscLocalisation));
|
|
||||||
|
|
||||||
public static ResourceManager DefaultResourceManager
|
|
||||||
{
|
|
||||||
get { return _defaultResourceManager; }
|
|
||||||
set { _defaultResourceManager = value; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -22,10 +22,8 @@ namespace Yavsc.Models.Haircut
|
||||||
// Bill description
|
// Bill description
|
||||||
public override string GetDescription()
|
public override string GetDescription()
|
||||||
{
|
{
|
||||||
string type = ResourcesHelpers.DefaultResourceManager
|
string type = ResourcesHelpers.GlobalLocalizer[this.GetType().Name];
|
||||||
.GetString(this.GetType().Name);
|
string gender = ResourcesHelpers.GlobalLocalizer[this.Prestation.Gender.ToString()];
|
||||||
string gender = ResourcesHelpers.DefaultResourceManager
|
|
||||||
.GetString(this.Prestation.Gender.ToString());
|
|
||||||
|
|
||||||
return $"{type} ({gender})";
|
return $"{type} ({gender})";
|
||||||
}
|
}
|
||||||
|
|
@ -88,8 +86,7 @@ namespace Yavsc.Models.Haircut
|
||||||
|
|
||||||
Name = "Coupe",
|
Name = "Coupe",
|
||||||
Description = $"Coupe "+
|
Description = $"Coupe "+
|
||||||
ResourcesHelpers.DefaultResourceManager
|
ResourcesHelpers.GlobalLocalizer[Prestation.Gender.ToString()]+ " "+
|
||||||
.GetString(Prestation.Gender.ToString())+ " "+
|
|
||||||
(Prestation.Gender == HairCutGenders.Women ?
|
(Prestation.Gender == HairCutGenders.Women ?
|
||||||
Prestation.Length == HairLength.Long ? longhairsuffix :
|
Prestation.Length == HairLength.Long ? longhairsuffix :
|
||||||
Prestation.Length == HairLength.HalfLong ? halflonghairsuffix :
|
Prestation.Length == HairLength.HalfLong ? halflonghairsuffix :
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ namespace Yavsc.Models.Haircut
|
||||||
|
|
||||||
public string CreateBoby()
|
public string CreateBoby()
|
||||||
{
|
{
|
||||||
return string.Format(ResourcesHelpers.DefaultResourceManager
|
return string.Format(ResourcesHelpers.GlobalLocalizer["RdvToPerf"], Client.UserName,
|
||||||
.GetString("RdvToPerf"), Client.UserName,
|
|
||||||
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
||||||
Location.Address,
|
Location.Address,
|
||||||
ActivityCode);
|
ActivityCode);
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ using Interfaces.Workflow;
|
||||||
public string CreateBody()
|
public string CreateBody()
|
||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
ResourcesHelpers.DefaultResourceManager.GetString("RdvToPerf"),
|
ResourcesHelpers.GlobalLocalizer["RdvToPerf"],
|
||||||
Client.UserName,
|
Client.UserName,
|
||||||
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
EventDate?.ToString("dddd dd/MM/yyyy à HH:mm"),
|
||||||
Location.Address,
|
Location.Address,
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ namespace Yavsc.ViewModels.Account
|
||||||
// ErrorMessage = "",
|
// ErrorMessage = "",
|
||||||
|
|
||||||
|
|
||||||
[Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "UserName")]
|
[Display(ResourceType = typeof(RegisterViewModel), Name = "UserName")]
|
||||||
[StringLength(102)]
|
[StringLength(102)]
|
||||||
[YaRegularExpression(@"[a-zA-Z0-9 .'_-]+", ErrorMessageResourceName="InvalidUserName", ErrorMessageResourceType = typeof(Yavsc.Resources.YavscLocalisation))]
|
[YaRegularExpression(@"[a-zA-Z0-9 .'_-]+", ErrorMessageResourceName="InvalidUserName", ErrorMessageResourceType = typeof(RegisterViewModel))]
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
|
|
||||||
[YaRequired()]
|
[YaRequired()]
|
||||||
|
|
@ -23,12 +23,12 @@ namespace Yavsc.ViewModels.Account
|
||||||
|
|
||||||
// ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")]
|
// ErrorMessage = "Les mots de passe doivent contenir au moins un caractère spécial, qui ne soit ni une lettre ni un chiffre.")]
|
||||||
|
|
||||||
[Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "Password")]
|
[Display(ResourceType = typeof(RegisterViewModel), Name = "Password")]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Password)]
|
[DataType(DataType.Password)]
|
||||||
[Display(ResourceType = typeof(Yavsc.Resources.YavscLocalisation), Name = "PasswordConfirm")]
|
[Display(ResourceType = typeof(RegisterViewModel), Name = "PasswordConfirm")]
|
||||||
[Compare("Password", ErrorMessageResourceName = "PassAndConfirmDontMach", ErrorMessageResourceType = typeof(Yavsc.Resources.YavscLocalisation) )]
|
[Compare("Password", ErrorMessageResourceName = "PassAndConfirmDontMach", ErrorMessageResourceType = typeof(RegisterViewModel) )]
|
||||||
public string ConfirmPassword { get; set; }
|
public string ConfirmPassword { get; set; }
|
||||||
|
|
||||||
public string GoogleRegId { get; set; }
|
public string GoogleRegId { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
"contrib"
|
"contrib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"embed": [
|
"copyToOutput": [
|
||||||
"Resources/**/*.resx"
|
"Resources/**/*.resx"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -77,4 +77,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ namespace Yavsc.Helpers
|
||||||
string strprestation = query.GetDescription();
|
string strprestation = query.GetDescription();
|
||||||
|
|
||||||
var yaev = query.CreateEvent("NewHairCutQuery",
|
var yaev = query.CreateEvent("NewHairCutQuery",
|
||||||
string.Format(Startup.GlobalLocalizer["HairCutQueryValidation"],query.Client.UserName),
|
string.Format(ResourcesHelpers.GlobalLocalizer["HairCutQueryValidation"],query.Client.UserName),
|
||||||
$"{query.Client.Id}");
|
$"{query.Client.Id}");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ namespace Yavsc
|
||||||
|
|
||||||
public static PayPalSettings PayPalSettings { get; private set; }
|
public static PayPalSettings PayPalSettings { get; private set; }
|
||||||
private static ILogger logger;
|
private static ILogger logger;
|
||||||
|
|
||||||
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
||||||
{
|
{
|
||||||
var devtag = env.IsDevelopment()?"D":"";
|
var devtag = env.IsDevelopment()?"D":"";
|
||||||
|
|
@ -256,9 +257,6 @@ namespace Yavsc
|
||||||
CheckServices(services);
|
CheckServices(services);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static IStringLocalizer GlobalLocalizer { get; private set; }
|
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
|
||||||
IOptions<SiteSettings> siteSettings,
|
IOptions<SiteSettings> siteSettings,
|
||||||
|
|
@ -271,7 +269,7 @@ namespace Yavsc
|
||||||
ILoggerFactory loggerFactory)
|
ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
GoogleSettings = googleSettings.Value;
|
GoogleSettings = googleSettings.Value;
|
||||||
GlobalLocalizer = localizer;
|
ResourcesHelpers.GlobalLocalizer = localizer;
|
||||||
SiteSetup = siteSettings.Value;
|
SiteSetup = siteSettings.Value;
|
||||||
Authority = siteSettings.Value.Authority;
|
Authority = siteSettings.Value.Authority;
|
||||||
var blogsDir = siteSettings.Value.UserFiles.Blog;
|
var blogsDir = siteSettings.Value.UserFiles.Blog;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue