diff --git a/docs/en/Tutorials/Part-2.md b/docs/en/Tutorials/Part-2.md index 50b90b516d..3e7a1bc735 100644 --- a/docs/en/Tutorials/Part-2.md +++ b/docs/en/Tutorials/Part-2.md @@ -135,22 +135,22 @@ Open the `en.json` (*the English translations*) file and change the content as s "CreationTime": "Creation time", "AreYouSure": "Are you sure?", "AreYouSureToDelete": "Are you sure you want to delete this item?", - "Enum:BookType:0": "Undefined", - "Enum:BookType:1": "Adventure", - "Enum:BookType:2": "Biography", - "Enum:BookType:3": "Dystopia", - "Enum:BookType:4": "Fantastic", - "Enum:BookType:5": "Horror", - "Enum:BookType:6": "Science", - "Enum:BookType:7": "Science fiction", - "Enum:BookType:8": "Poetry" + "Enum:BookType.Undefined": "Undefined", + "Enum:BookType.Adventure": "Adventure", + "Enum:BookType.Biography": "Biography", + "Enum:BookType.Dystopia": "Dystopia", + "Enum:BookType.Fantastic": "Fantastic", + "Enum:BookType.Horror": "Horror", + "Enum:BookType.Science": "Science", + "Enum:BookType.ScienceFiction": "Science fiction", + "Enum:BookType.Poetry": "Poetry" } } ```` * Localization key names are arbitrary. You can set any name. We prefer some conventions for specific text types; * Add `Menu:` prefix for menu items. - * Use `Enum::` naming convention to localize the enum members. When you do it like that, ABP can automatically localize the enums in some proper cases. + * Use `Enum:.` or `.` or `` naming convention to localize the enum members. When you do it like that, ABP can automatically localize the enums in some proper cases. If a text is not defined in the localization file, it **falls back** to the localization key (as ASP.NET Core's standard behavior). @@ -624,7 +624,7 @@ Open the `Books.razor` and replace the content as the following: Field="@nameof(BookDto.Type)" Caption="@L["Type"]"> - @L[$"Enum:BookType:{(int)context.Type}"] + @L[$"Enum:BookType.{Enum.GetName(context.Type)}"] - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1322,7 +1322,7 @@ We can now define a modal to edit the book. Add the following code to the end of @foreach (int bookTypeValue in Enum.GetValues(typeof(BookType))) { - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1459,7 +1459,7 @@ Here's the complete code to create the book management CRUD page, that has been Field="@nameof(BookDto.Type)" Caption="@L["Type"]"> - @L[$"Enum:BookType:{(int) context.Type}"] + @L[$"Enum:BookType.{Enum.GetName(context.Type)}"] - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1564,7 +1564,7 @@ Here's the complete code to create the book management CRUD page, that has been @foreach (int bookTypeValue in Enum.GetValues(typeof(BookType))) { - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } diff --git a/docs/zh-Hans/Tutorials/Part-2.md b/docs/zh-Hans/Tutorials/Part-2.md index 346927acbe..dc8d804d5e 100644 --- a/docs/zh-Hans/Tutorials/Part-2.md +++ b/docs/zh-Hans/Tutorials/Part-2.md @@ -135,15 +135,15 @@ successfully created the book with id: 439b0ea8-923e-8e1e-5d97-39f2c7ac4246 "CreationTime": "Creation time", "AreYouSure": "Are you sure?", "AreYouSureToDelete": "Are you sure you want to delete this item?", - "Enum:BookType:0": "Undefined", - "Enum:BookType:1": "Adventure", - "Enum:BookType:2": "Biography", - "Enum:BookType:3": "Dystopia", - "Enum:BookType:4": "Fantastic", - "Enum:BookType:5": "Horror", - "Enum:BookType:6": "Science", - "Enum:BookType:7": "Science fiction", - "Enum:BookType:8": "Poetry" + "Enum:BookType.Undefined": "Undefined", + "Enum:BookType.Adventure": "Adventure", + "Enum:BookType.Biography": "Biography", + "Enum:BookType.Dystopia": "Dystopia", + "Enum:BookType.Fantastic": "Fantastic", + "Enum:BookType.Horror": "Horror", + "Enum:BookType.Science": "Science", + "Enum:BookType.ScienceFiction": "Science fiction", + "Enum:BookType.Poetry": "Poetry" } } ```` @@ -152,7 +152,7 @@ successfully created the book with id: 439b0ea8-923e-8e1e-5d97-39f2c7ac4246 * 本地化关键字名称是任意的. 你可以设置任何名称. 对于特定的文本类型,我们更喜欢遵循一些约定: * 为按钮项添加 `Menu:` 前缀. - * 使用 `Enum::` 命名约定来本地化枚举成员. 当您这样做时ABP可以在某些适当的情况下自动将枚举本地化. + * 使用 `Enum::` 或 `.` 或 `` 命名约定来本地化枚举成员. 当您这样做时ABP可以在某些适当的情况下自动将枚举本地化. 如果未在本地化文件中定义文本,则文本将**回退**到本地化键(ASP.NET Core的标准行为). @@ -626,7 +626,7 @@ ABP提供了一个通用的基类,`AbpCrudPageBase<...>`,用来创建CRUD风格 Field="@nameof(BookDto.Type)" Caption="@L["Type"]"> - @L[$"Enum:BookType:{(int)context.Type}"] + @L[$"Enum:BookType.{Enum.GetName(context.Type)}"] - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1323,7 +1323,7 @@ delete(id: string) { @foreach (int bookTypeValue in Enum.GetValues(typeof(BookType))) { - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1460,7 +1460,7 @@ namespace Acme.BookStore.Blazor Field="@nameof(BookDto.Type)" Caption="@L["Type"]"> - @L[$"Enum:BookType:{(int) context.Type}"] + @L[$"Enum:BookType.{Enum.GetName(context.Type)}"] - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] } @@ -1565,7 +1565,7 @@ namespace Acme.BookStore.Blazor @foreach (int bookTypeValue in Enum.GetValues(typeof(BookType))) { - @L[$"Enum:BookType:{bookTypeValue}"] + @L[$"Enum:BookType.{Enum.GetName((BookType)bookTypeValue)}"] }