Support language type

This commit is contained in:
sunkaixuna 2021-10-22 21:34:10 +08:00
parent cc7510dc2e
commit eb74218fab
4 changed files with 35 additions and 3 deletions

View File

@ -30,6 +30,10 @@ namespace SqlSugar
/// </summary>
public InitKeyType InitKeyType = InitKeyType.Attribute;
/// <summary>
/// Exception prompt language
/// </summary>
public SugarLanguageType LanguageType { get=>ErrorMessage.SugarLanguageType; set=>ErrorMessage.SugarLanguageType=value; }
/// <summary>
///If true, there is only one connection instance in the same thread within the same connection string
//[Obsolete("use SqlSugar.Ioc")]
///// </summary>

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public enum SugarLanguageType
{
Default=0,
Chinese=1,
English=2
}
}

View File

@ -91,6 +91,7 @@
<Compile Include="Abstract\DeleteProvider\DeleteableProvider.cs" />
<Compile Include="Abstract\InsertableProvider\SplitInsertable.cs" />
<Compile Include="Entities\SqlSguarTransaction.cs" />
<Compile Include="Enum\LanguageType.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubAs.cs" />
<Compile Include="ExpressionsToSql\Subquery\Items\SubHaving.cs" />
<Compile Include="Interface\ISugarRepository.cs" />

View File

@ -6,6 +6,7 @@ namespace SqlSugar
{
internal static partial class ErrorMessage
{
internal static SugarLanguageType SugarLanguageType { get; set; } = SugarLanguageType.Default;
internal static string ObjNotExist
{
get
@ -43,10 +44,21 @@ namespace SqlSugar
internal static string GetThrowMessage(string enMessage, string cnMessage, params string[] args)
{
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
formatArgs.AddRange(args);
return string.Format(@"中文提示 : {1}
if (SugarLanguageType == SugarLanguageType.Default)
{
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
formatArgs.AddRange(args);
return string.Format(@"中文提示 : {1}
English Message : {0}", formatArgs.ToArray());
}
else if (SugarLanguageType == SugarLanguageType.English)
{
return enMessage;
}
else
{
return cnMessage;
}
}
}
}