-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37e5752
commit 5e70f90
Showing
7 changed files
with
77 additions
and
17 deletions.
There are no files selected for viewing
16 changes: 9 additions & 7 deletions
16
...gement/src/Lion.AbpPro.BasicManagement.Domain/Data/Seeds/AbpSettingDataSeedContributor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
using Volo.Abp.Data; | ||
using Volo.Abp.DependencyInjection; | ||
using Volo.Abp.Guids; | ||
using Volo.Abp.Localization; | ||
|
||
namespace Lion.AbpPro.BasicManagement.Data.Seeds | ||
{ | ||
public class AbpSettingDataSeedContributor : IDataSeedContributor, ITransientDependency | ||
{ | ||
private readonly ISettingManager _settingManager; | ||
private const string DefaultLanguageKey = "Abp.Localization.DefaultLanguage"; | ||
private const string DefaultLanguage = "zh-Hans"; | ||
public AbpSettingDataSeedContributor(ISettingManager settingManager) | ||
private const string Value = "zh-Hans"; | ||
private const string ProviderName = "G"; | ||
private readonly ISettingManagementStore _settingManagementStore; | ||
|
||
public AbpSettingDataSeedContributor(ISettingManagementStore settingManagementStore) | ||
{ | ||
_settingManager = settingManager; | ||
_settingManagementStore = settingManagementStore; | ||
} | ||
|
||
public async Task SeedAsync(DataSeedContext context) | ||
{ | ||
// 设置默认语言 | ||
await _settingManager.SetGlobalAsync(DefaultLanguageKey, DefaultLanguage); | ||
await _settingManagementStore.SetAsync(LocalizationSettingNames.DefaultLanguage, Value, ProviderName, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...vices/Microsoft/AspNetCore/Localization/LionAcceptLanguageHeaderRequestCultureProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Microsoft.AspNetCore.Localization; | ||
|
||
public class LionAcceptLanguageHeaderRequestCultureProvider : AcceptLanguageHeaderRequestCultureProvider | ||
{ | ||
public override async Task<ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext) | ||
{ | ||
var result = await base.DetermineProviderCultureResult(httpContext); | ||
|
||
try | ||
{ | ||
if (result == null || result.Cultures.Count <= 0) return result; | ||
|
||
var culture = result.Cultures.First(); | ||
|
||
// 判断是否以 zh-CN(浏览器默认),zh-HK(中国香港),zh-MO(中国澳门),zh-TW(中国台湾)区域开头,如果是一律采用简体中文 | ||
if (culture.Buffer != null && (culture.Buffer.StartsWith("zh-CN") || culture.Buffer.StartsWith("zh-HK") || culture.Buffer.StartsWith("zh-TW") || culture.Buffer.StartsWith("zh-MO"))) | ||
{ | ||
culture = new StringSegment("zh-Hans"); | ||
return new ProviderCultureResult(culture.Buffer, culture.Buffer); | ||
} | ||
} | ||
catch | ||
{ | ||
// ignore | ||
} | ||
|
||
return result; | ||
} | ||
} |