学习008-02-04-08 Localize UI Elements(本地化UI元素)

embedded/2024/10/22 16:47:15/

Localize UI Elements(本地化UI元素)

This lesson explains how to localize an XAF application. It describes how to translate UI elements into German and create a multi-language application.
本课介绍如何本地化XAF应用程序。它描述了如何将UI元素翻译成德语并创建多语言应用程序。

Note
For more information on localization, review the following topics:
有关本地化的更多信息,请查看以下主题:

  • How to: Localize an XAF .NET Application
  • Localization Basics

Step-by-Step Instructions(分步说明)

1.Add the following packages to the MySolution.Blazor.Server and MySolution.Win projects:
将以下包添加到MySolutions. Blazor.Server并MySolution.Win项目:
在这里插入图片描述

The packages are available only for the following languages: German (de), Spanish (es), and Japanese (ja). For other languages, use the Localization Service to download satellite assemblies. See the Localize Standard XAF Modules and DevExpress Controls Used in an Application topic for more information on how to use this service to localize XAF modules.
这些软件包仅适用于以下语言:德语(de)、西班牙语(es)和日语(ja)。对于其他语言,请使用本地化服务下载附属程序集。有关如何使用此服务本地化XAF模块的更多信息,请参阅应用程序主题中使用的本地化标准XAF模块和DevExpress控件。

2.In the MySolution.Blazor.Server project, open the appsettings.json file. Add the German language to the DevExpress:ExpressApp:Languages section and enable the runtime language switcher. You should always use the fully qualified language name that includes the country code (for example, de-DE instead of de):
在MySolutions. Blazor.Server项目中,打开appset.json文件。将德语添加到DevExpress:ExpressApp:语言部分并启用运行时语言切换器。您应该始终使用包含国家代码的完全限定语言名称(例如,de-DE而不是de):

appsettings.json {// ..."DevExpress"ef="/UI.html" title=ui>uiltin class-name">: {"ExpressApp"ef="/UI.html" title=ui>uiltin class-name">: {"Languages"ef="/UI.html" title=ui>uiltin class-name">: "en-US;de-DE","ShowLanguageSwitcher"ef="/UI.html" title=ui>uiltin class-name">: true,  // ...}}
} 

See the Current Culture in XAF ASP.NET Core Blazor Applications help section for more information on how an XAF ASP.NET Core Blazor application determines the default language.
有关XAF ASP.NETCore Blazor应用程序如何确定默认语言的更多信息,请参阅XAF ASP.NETCore Blazor应用程序中的当前区域性帮助部分。

3.Open the Model.DesignedDiffs.ef="/XAF.html" title=xaf>xafml file in the Model Editor. Focus the MySolution node and click Languages Manager… in the Language combo box on the Model Editor Toolbar.
在模型编辑器中打开Model. DesignedDiffs.ef="/XAF.html" title=xaf>xafml文件。聚焦MySolution节点,然后在模型编辑器工具栏的语言组合框中单击语言管理器…。
在这里插入图片描述

4.Add the target language in the invoked dialog and click OK.
在调用的对话框中添加目标语言,然后单击确定。
在这里插入图片描述

Save the model changes but don’t restart Visual Studio as the Languages Manager suggests. When you restart Visual Studio, the Model Editor loads the localized property value from the assemblies that you added previously and they become available at design time. For the purposes of this tutorial, these values aren’t necessary.
保存模型更改,但不要按照语言管理器的建议重新启动Visual Studio。重新启动Visual Studio时,模型编辑器会从您之前添加的程序集加载本地化属性值,这些值在设计时可用。出于本教程的目的,这些值不是必需的。

5.In the Solution Explorer, right-click the Model.DesignedDiffs.Localization.de-DE.ef="/XAF.html" title=xaf>xafml file and open its Properties window. Make sure that the Bef="/UI.html" title=ui>uild Action field is set to Embedded resource.
在解决方案资源管理器中,右键单击Model.DesignedDiffs.Localization.de-DE. ef="/XAF.html" title=xaf>xafml文件并打开其属性窗口。确保构建操作字段设置为嵌入式资源。

6.Open the Model.DesignedDiffs.ef="/XAF.html" title=xaf>xafml file in the Model Editor. Select the newly added language in the Language combo box.
在模型编辑器中打开Model. DesignedDiffs.ef="/XAF.html" title=xaf>xafml文件。在语言组合框中选择新添加的语言。
在这里插入图片描述

7.The localization packages translate standard strings/messages used in XAF. You also need to translate the strings that are unique to your current application (such as object or property names). To do that, locate properties denoted by the “globe” glyph in all the nodes and child nodes and assign a German translation to them. For the purposes of this tutorial, translate the Employees navigation item to Angestellte:
本地化包翻译XAF中使用的标准字符串/消息。您还需要翻译当前应用程序独有的字符串(例如对象或属性名称)。为此,请在所有节点和子节点中找到由“全局”字形表示的属性,并为它们分配德语翻译。出于本教程的目的,将员工导航项翻译为Angestellte:
在这里插入图片描述

Tip
Instead of going through each node to find strings that reqef="/UI.html" title=ui>uire translation one by one, use the Localization Tool to streamline your localization process.
不要通过每个节点逐个查找需要翻译的字符串,而是使用本地化工具来简化您的本地化过程。

8.In the MySolution.Win project, open the Model.ef="/XAF.html" title=xaf>xafml file in the Model Editor and navigate to the MySolution node. Set the PreferredLanguage property to de-De to display the localized strings in the UI when you run the Windows Forms application.
在MySolution.Win项目中,在模型编辑器中打开Model. ef="/XAF.html" title=xaf>xafml文件并导航到MySolution节点。将PreferredLanguage属性设置为de-De以在运行Windows窗体应用程序时在UI中显示本地化字符串。

9.Run the application.
运行应用程序。

In ASP.NET Core Blazor, you can switch the language in the application settings menu. To access the settings menu, click the gear icon in the upper right corner:
在ASP.NETCore Blazor中,您可以在应用程序设置菜单中切换语言。要访问设置菜单,请单击右上角的齿轮图标:
在这里插入图片描述

10.The application should display the German translation of the Employees navigation item.
应用程序应显示员工导航项的德语翻译。

ASP.NET Core Blazor
在这里插入图片描述

Windows Forms
在这里插入图片描述

Next Lesson(下一课)

Assign a Standard Image
分配标准图像


http://www.ppmy.cn/embedded/87416.html

相关文章

Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别

GenericJackson2JsonRedisSerializer 和 Jackson2JsonRedisSerializer 是 Spring Data Redis 提供的两种基于 Jackson 的 Redis 序列化器。 它们的主要区别在于序列化和反序列化的方式以及适用的场景。 GenericJackson2JsonRedisSerializer 序列化方式:在序列化对…

运维-6-采用LPG搭建轻量级日志收集系统

参考Grafana 安装配置教程 1 Grafana Grafana是一个通用的可视化工具。对于Grafana而言,Prometheus这类为其提供数据的对象均称为数据源(Data Source)。目前,Grafana官方提供了对:Graphite, InfluxDB, OpenTSDB, tde…

构建稳固与安全的网络环境:从微软蓝屏事件中的教训学习

近日,一场由微软视窗系统软件更新引发的全球性“微软蓝屏”事件震惊了整个科技界。这次事件不仅暴露了现代IT基础设施在面对大规模软件缺陷时的脆弱性,也引发了对网络安全与系统稳定性的深刻思考。在本文中,我们将探讨这次事件的根源、影响以…

达梦数据库系列—32.多版本并发控制MVCC

在多版本控制以前,数据库仅通过锁机制来实现并发控制。数据库对读操作上共享锁,写操作上排他锁,这种锁机制虽然解决了并发问题,但影响了并发性。 DM 数据库基于物理记录和回滚记录实现行级多版本支持,数据页中只保留物…

ChatGPT:宽列数据库是什么?

ChatGPT:宽列数据库是什么? 宽列数据库(Wide-Column Store)是一种 NoSQL 数据库,它的设计灵感来自于 Google 的 Bigtable。宽列数据库适用于处理大规模的分布式数据存储,特别是在需要高性能读写、灵活的数据…

服务器是否需要安装杀毒软件

现在许多服务器都自带杀毒软件,这些软件可以更好的保护服务器的安全,防止使用者的信息被泄露。那么服务器是否需要杀毒软件,这里壹基比小鑫就和大家一起看看。 一、为什么要装服务器杀毒软件? 装服务器杀毒软件主要是保护服务器安…

CSA笔记9-磁盘管理(2)

分区挂载 挂载:将该文件系统中的内容与指定的目录关联起来,使得你可以通过该目录来访问文件系统中的文件和目录。 mount 命令用来挂载文件系统 #挂载/dev/sda1和/dev/sda2 [rootlocalhost ~]# mkdir test{1..2} [rootlocalhost ~]# ll test1 te…

UPLOAD-LABS靶场[超详细通关教程,通关攻略]

---------------------------------------- 靶场环境: 下载链接: https://codeload.github.com/c0ny1/upload-labs/zip/refs/heads/master 使用小皮集成环境来完成这个靶场 将文件放到WWW目录下就可以进行访问 ------------------------------------…