-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆕 feat(I18n): Add I18n component (#945)
* 🆕 feat(I18n): Add I18n component for library, and add contribute components for docs * 📝 docs(i18n-component): add docs
- Loading branch information
Showing
15 changed files
with
161 additions
and
7 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
src/Docs/Masa.Blazor.Docs/Examples/components/i18ns/Args.razor
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,5 @@ | ||
<span class="grey--text"> | ||
<MI18n Key="$masaBlazor.pagination.ariaLabel.page" /> | ||
</span> | ||
<MIcon>mdi-arrow-right-bold</MIcon> | ||
<MI18n Key="$masaBlazor.pagination.ariaLabel.page" Args="@(new object[] { "All components" })"></MI18n> |
15 changes: 15 additions & 0 deletions
15
src/Docs/Masa.Blazor.Docs/Examples/components/i18ns/Placeholder.razor
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,15 @@ | ||
<span class="grey--text"> | ||
<MI18n Key="$masaBlazor.pagination.ariaLabel.page" /> | ||
</span> | ||
<MIcon>mdi-arrow-right-bold</MIcon> | ||
<MI18n Key="$masaBlazor.pagination.ariaLabel.page"> | ||
<PlaceholderContent> | ||
@if (context == 0) | ||
{ | ||
<a class="text-decoration-none primary--text font-weight-medium" | ||
href="/blazor/components/all"> | ||
All components | ||
</a> | ||
} | ||
</PlaceholderContent> | ||
</MI18n> |
11 changes: 11 additions & 0 deletions
11
src/Docs/Masa.Blazor.Docs/Examples/components/i18ns/Usage.razor
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,11 @@ | ||
<MRow> | ||
<MCol Cols="4" Class="text-center"> | ||
<MI18n Key="$masaBlazor.close" /> | ||
</MCol> | ||
<MCol Cols="4" Class="text-center"> | ||
<MI18n Key="$masaBlazor.save" /> | ||
</MCol> | ||
<MCol Cols="4" Class="text-center"> | ||
<MI18n Key="$masaBlazor.cancel" /> | ||
</MCol> | ||
</MRow> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ | |
] | ||
}, | ||
"hover", | ||
"i18ns", | ||
"icons", | ||
"image-captcha", | ||
"images", | ||
|
29 changes: 29 additions & 0 deletions
29
src/Docs/Masa.Blazor.Docs/wwwroot/pages/components/i18ns/en-US.md
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 @@ | ||
--- | ||
title: I18n | ||
desc: "The **MI18n** component that helps you use localization." | ||
--- | ||
|
||
## Usage | ||
|
||
No manual injection of **I18n** is required. | ||
|
||
<masa-example file="Examples.components.i18ns.Usage"></masa-example> | ||
|
||
## Examples | ||
|
||
### Props | ||
|
||
#### Args | ||
|
||
The same as the `args` parameter of `String.Format`. | ||
|
||
<masa-example file="Examples.components.i18ns.Args"></masa-example> | ||
|
||
### Contents | ||
|
||
#### Placeholder | ||
|
||
Inserting strings is supported, and custom components can be inserted for each index using `PlaceholderContent`. | ||
|
||
<masa-example file="Examples.components.i18ns.Placeholder"></masa-example> | ||
|
26 changes: 26 additions & 0 deletions
26
src/Docs/Masa.Blazor.Docs/wwwroot/pages/components/i18ns/zh-CN.md
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,26 @@ | ||
--- | ||
title: I18n | ||
desc: "**MI18n** 组件能帮你使用本地化。" | ||
--- | ||
|
||
## 使用 | ||
|
||
不需要手动注入 **I18n**。 | ||
|
||
<masa-example file="Examples.components.i18ns.Usage"></masa-example> | ||
|
||
## 示例 | ||
|
||
### 属性 | ||
|
||
同等于 `String.Format` 的 `args` 参数。 | ||
|
||
<masa-example file="Examples.components.i18ns.Args"></masa-example> | ||
|
||
### 插槽 | ||
|
||
#### 占位符 | ||
|
||
插入字符串是支持的,而且可以使用 `PlaceholderContent` 对每个索引插入自定义组件。 | ||
|
||
<masa-example file="Examples.components.i18ns.Placeholder"></masa-example> |
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,23 @@ | ||
@inject I18n I18n | ||
|
||
<div class="ordinary-text d-flex align-center justify-space-between"> | ||
<div class="font-weight-medium d-flex align-baseline grow flex-wrap"> | ||
<MI18n Key="contribute.edit-page" Class="mb-2 mb-md-0"> | ||
<PlaceholderContent> | ||
@if (context == 0) | ||
{ | ||
<AppLink Href="@GithubUri" Content="Github"></AppLink> | ||
} | ||
</PlaceholderContent> | ||
</MI18n> | ||
|
||
<MSpacer Class="hidden-sm-and-down"></MSpacer> | ||
</div> | ||
</div> | ||
|
||
@code { | ||
|
||
[Parameter, EditorRequired] | ||
public string GithubUri { get; set; } = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Masa.Blazor; | ||
|
||
public partial class MI18n : BI18n | ||
{ | ||
protected override void SetComponentClass() | ||
{ | ||
base.SetComponentClass(); | ||
|
||
CssProvider.Apply(cssBuilder => { cssBuilder.Add("m-i18n"); }); | ||
} | ||
} |
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
Large diffs are not rendered by default.
Oops, something went wrong.