Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<PackageReference Include="BootstrapBlazor.PdfViewer" Version="9.0.6" />
<PackageReference Include="BootstrapBlazor.Player" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor.RDKit" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor.Region" Version="9.0.0" />
<PackageReference Include="BootstrapBlazor.SignaturePad" Version="9.0.1" />
<PackageReference Include="BootstrapBlazor.SmilesDrawer" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor.Sortable" Version="9.0.3" />
Expand Down
14 changes: 14 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Regions.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@page "/region"
@inject IStringLocalizer<Regions> Localizer

<h3>@Localizer["RegionTitle"]</h3>

<h4>@Localizer["RegionDescription"]</h4>

<PackageTips Name="BootstrapBlazor.Region" />

<DemoBlock Title="@Localizer["RegionNormalTitle"]"
Introduction="@Localizer["RegionNormalIntro"]"
Name="Normal">
<SelectRegion Value="@_value"></SelectRegion>
</DemoBlock>
14 changes: 14 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/Regions.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

namespace BootstrapBlazor.Server.Components.Samples;

/// <summary>
/// 行政区域选择器示例
/// </summary>
public partial class Regions
{
private string _value = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ void AddForm(DemoMenuItem item)
Url = "floating-label"
},
new()
{
IsNew = true,
Text = Localizer["Region"],
Url = "region"
},
new()
{
Text = Localizer["ListGroup"],
Url = "list-group"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public static IServiceCollection AddBootstrapBlazorServices(this IServiceCollect
// 增加 JuHe 定位服务
services.AddBootstrapBlazorJuHeIpLocatorService();

// 增加 IRegionService
services.AddBootstrapBlazorRegionService();

// 增加 PetaPoco ORM 数据服务操作类
// 需要时打开下面代码
//services.AddPetaPoco(option =>
Expand Down
9 changes: 8 additions & 1 deletion src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -4872,7 +4872,8 @@
"OpcDaService": "OpcDaServer",
"Navbar": "Navbar",
"TaskDashBoard": "TaskDashBoard",
"Dom2ImageService": "IDom2HtmlService"
"Dom2ImageService": "IDom2HtmlService",
"Region": "Region Selector"
},
"BootstrapBlazor.Server.Components.Samples.Table.TablesHeader": {
"TablesHeaderTitle": "Header grouping function",
Expand Down Expand Up @@ -7220,5 +7221,11 @@
"Dom2ImageButtonText": "Convert",
"Dom2ImageDownloadText": "Download",
"Dom2ImageFullText": "Capture"
},
"BootstrapBlazor.Server.Components.Samples.Regions": {
"RegionTitle": "Region",
"RegionDescription": "A simple region cascade selector, provide 4 levels Chinese administrative division data",
"RegionNormalTitle": "Basic usage",
"RegionNormalIntro": "Use grouping to switch the selection mode for displaying administrative areas"
}
}
9 changes: 8 additions & 1 deletion src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4872,7 +4872,8 @@
"OpcDaService": "OpcDaServer 服务",
"Navbar": "导航栏 Navbar",
"TaskDashBoard": "任务管理器 TaskDashBoard",
"Dom2ImageService": "节点转图片服务 IDom2HtmlService"
"Dom2ImageService": "节点转图片服务 IDom2HtmlService",
"Region": "行政区域选择器 Region"
},
"BootstrapBlazor.Server.Components.Samples.Table.TablesHeader": {
"TablesHeaderTitle": "表头分组功能",
Expand Down Expand Up @@ -7220,5 +7221,11 @@
"Dom2ImageButtonText": "转换",
"Dom2ImageDownloadText": "下载",
"Dom2ImageFullText": "长截图"
},
"BootstrapBlazor.Server.Components.Samples.Regions": {
"RegionTitle": "Region 行政区域选择器",
"RegionDescription": "提供 4 级行政区划选择器",
"RegionNormalTitle": "基本用法",
"RegionNormalIntro": "使用分组切换显示行政区域的选择模式"
}
}
3 changes: 2 additions & 1 deletion src/BootstrapBlazor.Server/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@
"navbar": "Navbars",
"task-board": "TaskBoard",
"modbus-factory": "Modbus\\ModbusFactories",
"serial-port-factory": "SerialPorts\\SerialPortFactories"
"serial-port-factory": "SerialPorts\\SerialPortFactories",
"region": "Regions"
},
"video": {
"table": "BV1ap4y1x7Qn?p=1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public abstract class PopoverDropdownBase<TValue> : ValidateBase<TValue>
/// 获得 CustomClass 字符串
/// </summary>
protected virtual string? CustomClassString => CssBuilder.Default(CustomClass)
.AddClass("popover-region")
.AddClass("shadow", ShowShadow)
.Build();
}
14 changes: 7 additions & 7 deletions src/BootstrapBlazor/Localization/Json/JsonStringLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override LocalizedString this[string name]
private string? GetStringFromJson(string name)
{
// get string from json localization file
var localizerStrings = MegerResolveLocalizers(CacheManager.GetAllStringsByTypeName(Assembly, typeName));
var localizerStrings = MergeResolveLocalizers(CacheManager.GetAllStringsByTypeName(Assembly, typeName));
var cacheKey = $"name={name}&culture={CultureInfo.CurrentUICulture.Name}";
string? ret = null;
if (!_missingManifestCache.ContainsKey(cacheKey))
Expand Down Expand Up @@ -143,7 +143,7 @@ public override LocalizedString this[string name]
if (baseType != type)
{
var baseAssembly = baseType.Assembly;
var localizerStrings = MegerResolveLocalizers(CacheManager.GetAllStringsByTypeName(baseAssembly, baseType.FullName!));
var localizerStrings = MergeResolveLocalizers(CacheManager.GetAllStringsByTypeName(baseAssembly, baseType.FullName!));
var l = localizerStrings.Find(i => i.Name == name);
if (l is { ResourceNotFound: false })
{
Expand All @@ -154,7 +154,7 @@ public override LocalizedString this[string name]
return ret;
}

private List<LocalizedString> MegerResolveLocalizers(IEnumerable<LocalizedString>? localizerStrings)
private List<LocalizedString> MergeResolveLocalizers(IEnumerable<LocalizedString>? localizerStrings)
{
var localizers = new List<LocalizedString>(CacheManager.GetTypeStringsFromResolve(typeName));
if (localizerStrings != null)
Expand All @@ -174,7 +174,7 @@ private void HandleMissingResourceItem(string name)
_missingManifestCache.TryAdd($"name={name}&culture={CultureInfo.CurrentUICulture.Name}", null);
}

private List<LocalizedString>? _allLocalizerdStrings;
private List<LocalizedString>? _allLocalizedStrings;

/// <summary>
/// 获取当前语言的所有资源信息
Expand All @@ -183,15 +183,15 @@ private void HandleMissingResourceItem(string name)
/// <returns></returns>
public override IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
{
if (_allLocalizerdStrings == null)
if (_allLocalizedStrings == null)
{
var items = GetAllStringsFromService()
?? GetAllStringsFromBase()
?? GetAllStringsFromJson();

_allLocalizerdStrings = MegerResolveLocalizers(items);
_allLocalizedStrings = MergeResolveLocalizers(items);
}
return _allLocalizerdStrings;
return _allLocalizedStrings;

// 1. 从注入服务中获取所有资源信息
// get all strings from the other inject service
Expand Down
Loading