Skip to content

Commit c634c1d

Browse files
committed
Merge branch 'dev' of https://github.com/abpframework/abp into feat/layout-components
2 parents 5bb96dd + fc57310 commit c634c1d

File tree

82 files changed

+1500
-77
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1500
-77
lines changed

docs/zh-Hans/Localization.md

+50-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ JSON文件位于 "/Localization/Resources/Test" 项目文件夹下, 如下图所
8686
* 每个本地化文件都需要定义 `culture` (文化) 代码 (例如 "en" 或 "en-US").
8787
* `texts` 部分只包含本地化字符串的键值集合 (键也可能有空格).
8888

89+
### 默认资源
90+
91+
可以将 `AbpLocalizationOptions.DefaultResourceType` 设置为资源类型,在未指定本地化资源时使用:
92+
93+
````csharp
94+
Configure<AbpLocalizationOptions>(options =>
95+
{
96+
options.DefaultResourceType = typeof(TestResource);
97+
});
98+
````
99+
100+
> [启动模板]](Startup-Templates/Application.md) 设置 `DefaultResourceType` 为应用程序的本地化资源.
101+
102+
请参阅下面的*客户端*部分获取用例
103+
89104
##### 简短的本地化资源名称
90105

91106
本地化资源也可以在客户端(JavaScript)使用. 因此, 为本地化资源设置一个简短的名称可以更方便的本地化文本. 例如:
@@ -165,6 +180,10 @@ public class MyService
165180
}
166181
````
167182

183+
##### 格式参数
184+
185+
格式参数可以在本地化Key参数后传递,如果你的消息是 `Hello {0}, welcome!`,可以将 `{0}` 传递给localizer,例如: `_localizer["HelloMessage", "John"]`.
186+
168187
###### 在Razor视图/Page中简单的用法
169188

170189
````c#
@@ -179,7 +198,9 @@ public class MyService
179198

180199
ABP提供了JavaScript服务, 可以在客户端使用相同的本地化文本.
181200

182-
获取本地化资源:
201+
#### getResource
202+
203+
`abp.localization.getResource` 函数用于获取本地化资源:
183204

184205
````js
185206
var testResource = abp.localization.getResource('Test');
@@ -191,6 +212,33 @@ var testResource = abp.localization.getResource('Test');
191212
var str = testResource('HelloWorld');
192213
````
193214

194-
## See Also
215+
#### 本地化
216+
217+
`abp.localization.localize` 函数用于获取本地化文本,你可以传递本地化Key和资源名称:
218+
219+
````js
220+
var str = abp.localization.localize('HelloWorld', 'Test');
221+
````
222+
223+
`HelloWorld` 是本地化文本的Key, `Test` 是本地化资源的名称.
224+
225+
如果未指定本地化资源名称,它使用 `AbpLocalizationOptions` 中定义的默认本地化资源(参见上面的*默认资源*部分). 例:
226+
227+
````js
228+
var str = abp.localization.localize('HelloWorld'); //uses the default resource
229+
````
230+
231+
##### 格式参数
232+
233+
如果本地化字符串包含参数, 例如 `Hello {0}, welcome!`. 你可以将参数传递给本地化方法. 例:
234+
235+
````js
236+
var str1 = abp.localization.getResource('Test')('HelloWelcomeMessage', 'John');
237+
var str2 = abp.localization.localize('HelloWorld', 'Test', 'John');
238+
````
239+
240+
上面的两个示例都会输出 `Hello John, welcome!`.
241+
242+
## 另请参阅
195243

196244
* [Angular UI中的本地化](UI/Angular/Localization.md)

docs/zh-Hans/Object-Extensions.md

+100
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,106 @@ ObjectExtensionManager.Instance
176176
177177
`options` 有一个名为 `Configuration` 的字典,该字典存储对象扩展定义甚至可以扩展. EF Core使用它来将其他属性映射到数据库中的表字段. 请参阅[扩展实体文档](Customizing-Application-Modules-Extending-Entities.md).
178178

179+
#### CheckPairDefinitionOnMapping
180+
181+
控制在映射两个可扩展对象时如何检查属性定义. 请参阅*对象到对象映射*部分,了解 `CheckPairDefinitionOnMapping` 选项.
182+
183+
## Validation
184+
185+
你可能要为你定义的额外属性添加一些 **验证规则**. `AddOrUpdateProperty` 方法选项允许进行验证的方法有两种:
186+
187+
1. 你可以为属性添加 **数据注解 attributes**.
188+
2. 你可以给定一个action(代码块)执行 **自定义验证**.
189+
190+
当你在**自动验证**的方法(例如:控制器操作,页面处理程序方法,应用程序服务方法...)中使用对象时,验证会工作. 因此,每当扩展对象被验证时,所有额外的属性都会被验证.
191+
192+
### 数据注解 Attributes
193+
194+
所有标准的数据注解Attributes对于额外属性都是有效的. 例:
195+
196+
````csharp
197+
ObjectExtensionManager.Instance
198+
.AddOrUpdateProperty<IdentityUserCreateDto, string>(
199+
"SocialSecurityNumber",
200+
options =>
201+
{
202+
options.Attributes.Add(new RequiredAttribute());
203+
options.Attributes.Add(
204+
new StringLengthAttribute(32) {
205+
MinimumLength = 6
206+
}
207+
);
208+
});
209+
````
210+
211+
使用以上配置,如果没有提供有效的 `SocialSecurityNumber` 值, `IdentityUserCreateDto` 对象将是无效的.
212+
213+
### 自定义验证
214+
215+
如果需要,可以添加一个自定义action验证额外属性. 例:
216+
217+
````csharp
218+
ObjectExtensionManager.Instance
219+
.AddOrUpdateProperty<IdentityUserCreateDto, string>(
220+
"SocialSecurityNumber",
221+
options =>
222+
{
223+
options.Validators.Add(context =>
224+
{
225+
var socialSecurityNumber = context.Value as string;
226+
227+
if (socialSecurityNumber == null ||
228+
socialSecurityNumber.StartsWith("X"))
229+
{
230+
context.ValidationErrors.Add(
231+
new ValidationResult(
232+
"Invalid social security number: " + socialSecurityNumber,
233+
new[] { "SocialSecurityNumber" }
234+
)
235+
);
236+
}
237+
});
238+
});
239+
````
240+
241+
`context.ServiceProvider` 可以解析服务.
242+
243+
除了为单个属性添加自定义验证逻辑外,还可以添加在对象级执行的自定义验证逻辑. 例:
244+
245+
````csharp
246+
ObjectExtensionManager.Instance
247+
.AddOrUpdate<IdentityUserCreateDto>(objConfig =>
248+
{
249+
//Define two properties with their own validation rules
250+
251+
objConfig.AddOrUpdateProperty<string>("Password", propertyConfig =>
252+
{
253+
propertyConfig.Attributes.Add(new RequiredAttribute());
254+
});
255+
256+
objConfig.AddOrUpdateProperty<string>("PasswordRepeat", propertyConfig =>
257+
{
258+
propertyConfig.Attributes.Add(new RequiredAttribute());
259+
});
260+
261+
//Write a common validation logic works on multiple properties
262+
263+
objConfig.Validators.Add(context =>
264+
{
265+
if (context.ValidatingObject.GetProperty<string>("Password") !=
266+
context.ValidatingObject.GetProperty<string>("PasswordRepeat"))
267+
{
268+
context.ValidationErrors.Add(
269+
new ValidationResult(
270+
"Please repeat the same password!",
271+
new[] { "Password", "PasswordRepeat" }
272+
)
273+
);
274+
}
275+
});
276+
});
277+
````
278+
179279
## 对象到对象映射
180280

181281
假设你已向可扩展的实体对象添加了额外的属性并使用了自动[对象到对象的映射](Object-To-Object-Mapping.md)将该实体映射到可扩展的DTO类. 在这种情况下你需要格外小心,因为额外属性可能包含**敏感数据**,这些数据对于客户端不可用.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"culture": "de",
3+
"texts": {
4+
"GivenTenantIsNotAvailable": "Der angegebene Mandant ist nicht verfügbar: {0}",
5+
"Tenant": "Mandant",
6+
"Switch": "wechseln",
7+
"Name": "Name",
8+
"SwitchTenantHint": "Lassen Sie das Namensfeld leer, um auf die Host-Seite zu wechseln.",
9+
"SwitchTenant": "Mandant wechseln",
10+
"NotSelected": "Nicht ausgewählt"
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"culture": "nl",
3+
"texts": {
4+
"GivenTenantIsNotAvailable": "Gegeven klant is niet beschikbaar: {0}",
5+
"Tenant": "Klant",
6+
"Switch": "Schakel over",
7+
"Name": "Name",
8+
"SwitchTenantHint": "Laat het naamveld leeg om over te schakelen naar de hostkant.",
9+
"SwitchTenant": "Klant wisselen",
10+
"NotSelected": "Niet geselecteerd"
11+
}
12+
}

framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/DefaultBrandingProvider.cs

+2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ public class DefaultBrandingProvider : IBrandingProvider, ITransientDependency
77
public virtual string AppName => "MyApplication";
88

99
public virtual string LogoUrl => null;
10+
11+
public virtual string LogoReverseUrl => null;
1012
}
1113
}

framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Components/IBrandingProvider.cs

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ public interface IBrandingProvider
44
{
55
string AppName { get; }
66

7+
/// <summary>
8+
/// Logo on white background
9+
/// </summary>
710
string LogoUrl { get; }
11+
12+
/// <summary>
13+
/// Logo on dark background
14+
/// </summary>
15+
string LogoReverseUrl { get; }
816
}
917
}

framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/VirtualFileSystem/WebContentFileProvider.cs

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using JetBrains.Annotations;
45
using Microsoft.AspNetCore.Hosting;
56
using Microsoft.Extensions.FileProviders;
7+
using Microsoft.Extensions.Hosting;
68
using Microsoft.Extensions.Options;
79
using Microsoft.Extensions.Primitives;
810
using Volo.Abp.DependencyInjection;
@@ -91,9 +93,27 @@ public virtual IChangeToken Watch(string filter)
9193

9294
protected virtual IFileProvider CreateFileProvider()
9395
{
94-
return new CompositeFileProvider(
96+
var fileProviders = new List<IFileProvider>()
97+
{
9598
new PhysicalFileProvider(_hostingEnvironment.ContentRootPath),
9699
_virtualFileProvider
100+
};
101+
102+
if (_hostingEnvironment.IsDevelopment() &&
103+
_hostingEnvironment.WebRootFileProvider is CompositeFileProvider compositeFileProvider)
104+
{
105+
var staticWebAssetsFileProvider = compositeFileProvider
106+
.FileProviders
107+
.FirstOrDefault(f => f.GetType().Name.Equals("StaticWebAssetsFileProvider"));
108+
109+
if (staticWebAssetsFileProvider != null)
110+
{
111+
fileProviders.Add(staticWebAssetsFileProvider);
112+
}
113+
}
114+
115+
return new CompositeFileProvider(
116+
fileProviders
97117
);
98118
}
99119

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"culture": "de",
3+
"texts": {
4+
"MaxResultCountExceededExceptionMessage": "{0} kann nicht mehr als {1} sein! Erhöhen Sie {2}.{3} auf der Serverseite, um mehr Ergebnisse zu ermöglichen."
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"culture": "nl",
3+
"texts": {
4+
"MaxResultCountExceededExceptionMessage": "{0} kan niet meer dan {1} zijn! Vergroot {2}.{3} op de server om een groter resultaat toe te staan."
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"culture": "de",
3+
"texts": {
4+
"DisplayName:Abp.Mailing.DefaultFromAddress": "Standard-Absenderadresse",
5+
"DisplayName:Abp.Mailing.DefaultFromDisplayName": "Standard-Absendername",
6+
"DisplayName:Abp.Mailing.Smtp.Host": "Host",
7+
"DisplayName:Abp.Mailing.Smtp.Port": "Port",
8+
"DisplayName:Abp.Mailing.Smtp.UserName": "Benutzername",
9+
"DisplayName:Abp.Mailing.Smtp.Password": "Passwort",
10+
"DisplayName:Abp.Mailing.Smtp.Domain": "Domain",
11+
"DisplayName:Abp.Mailing.Smtp.EnableSsl": "SSL aktivieren",
12+
"DisplayName:Abp.Mailing.Smtp.UseDefaultCredentials": "Standard-Anmeldeinformationen verwenden",
13+
"Description:Abp.Mailing.DefaultFromAddress": "Die Standard-Absenderadresse",
14+
"Description:Abp.Mailing.DefaultFromDisplayName": "Der Standard-Absendername",
15+
"Description:Abp.Mailing.Smtp.Host": "Der Name oder die IP-Adresse des für SMTP-Transaktionen verwendeten Hosts.",
16+
"Description:Abp.Mailing.Smtp.Port": "Der für SMTP-Transaktionen verwendete Port.",
17+
"Description:Abp.Mailing.Smtp.UserName": "Benutzername, der mit den Anmeldedaten verknüpft ist.",
18+
"Description:Abp.Mailing.Smtp.Password": "Das Passwort für den Benutzernamen, der mit den Anmeldeinformationen verknüpft ist.",
19+
"Description:Abp.Mailing.Smtp.Domain": "Die Domäne oder der Computername, der die Anmeldeinformationen verifiziert.",
20+
"Description:Abp.Mailing.Smtp.EnableSsl": "Bestimmt, ob der SmptClient Secure Sockets Layer (SSL) zur Verschlüsselung der Verbindung verwendet.",
21+
"Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Bestimmt, ob die DefaultCredentials mit Anfragen gesendet werden."
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"culture": "nl",
3+
"texts": {
4+
"DisplayName:Abp.Mailing.DefaultFromAddress": "Standard vanaf adres",
5+
"DisplayName:Abp.Mailing.DefaultFromDisplayName": "Standaard vanaf weergave naam",
6+
"DisplayName:Abp.Mailing.Smtp.Host": "Host",
7+
"DisplayName:Abp.Mailing.Smtp.Port": "Poort",
8+
"DisplayName:Abp.Mailing.Smtp.UserName": "Gebruiker naam",
9+
"DisplayName:Abp.Mailing.Smtp.Password": "wachtwoord",
10+
"DisplayName:Abp.Mailing.Smtp.Domain": "Domein",
11+
"DisplayName:Abp.Mailing.Smtp.EnableSsl": "SSL toestaan",
12+
"DisplayName:Abp.Mailing.Smtp.UseDefaultCredentials": "Gebruik standaard inloggegevens",
13+
"Description:Abp.Mailing.DefaultFromAddress": "Standard vanaf adres",
14+
"Description:Abp.Mailing.DefaultFromDisplayName": "Standaard vanaf weergave naam",
15+
"Description:Abp.Mailing.Smtp.Host": "De naam of het IP-adres van de host die wordt gebruikt voor SMTP-transacties.",
16+
"Description:Abp.Mailing.Smtp.Port": "De poort die wordt gebruikt voor SMTP-transacties.",
17+
"Description:Abp.Mailing.Smtp.UserName": "Gebruikersnaam gekoppeld aan de inloggegevens.",
18+
"Description:Abp.Mailing.Smtp.Password": "Het wachtwoord voor de gebruikersnaam die bij de inloggegevens hoort.",
19+
"Description:Abp.Mailing.Smtp.Domain": "Het domein of de computernaam die de inloggegevens verifieert.",
20+
"Description:Abp.Mailing.Smtp.EnableSsl": "Of de SmtpClient Secure Sockets Layer (SSL) gebruikt om de verbinding te versleutelen.",
21+
"Description:Abp.Mailing.Smtp.UseDefaultCredentials": "Of de standaard inloggegevens worden verzonden met verzoeken."
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"culture": "de",
3+
"texts": {
4+
"DisplayName:Abp.Localization.DefaultLanguage": "Standardsprache",
5+
"Description:Abp.Localization.DefaultLanguage": "Die Standardsprache der Anwendung."
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"culture": "nl",
3+
"texts": {
4+
"DisplayName:Abp.Localization.DefaultLanguage": "Standaard taal",
5+
"Description:Abp.Localization.DefaultLanguage": "De standaardtaal van de applicatie."
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"culture": "de",
3+
"texts": {
4+
"Menu:Administration": "Administration"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"culture": "nl",
3+
"texts": {
4+
"Menu:Administration": "Administratie"
5+
}
6+
}

0 commit comments

Comments
 (0)