XAF应用开发教程(八) 汉化与多国语言支持

https://www.cnblogs.com/foreachlife/p/5067380.html

使用了XAF开发时,汉化是一个比较常的问题。

要实现汉化很简单:

1.在这里下载汉化资源文件。这里演示的版本是15.1.X的

2.文件下载后将:文件解压到目录    <你的项目>\BIN\ 下面。 解压后如下所示:

这一步的功能是:汉化多数控件中的使用的文字资源。这是官方提供的方法,也有些字符串是没有被汉化的。因为DEV支持的语言也不少,也制做了许多国家的语言包。但CN的资源包还没有做完全汉化。

注意:上例中是在web中,在Win中,同样需要将上面的文件解压过去。

3.XAF中内容的汉化,因为XAF是基于控件开发的,所以控件汉化也算是完成了一部分XAF的汉化。另外不在控件中的,就需要在XAFML中进行汉化了。

In this topic, you will learn how to localize a typical XAF application. We recommend that you review the Application Model Basics andLocalization Basics topics before proceeding. You can localize an XAF application in two ways.

  • Directly in the Model Editor by translating each localizable value.
  • Using the Localization Tool, which can be invoked from the Model Editor Toolbar. This tool gathers all the localizable values in one grid, and provides the import/export functionality as well as the ability to use the Microsoft Translator service.

These two approaches are described below. We recommend using the Localization Tool, because it makes the localization process quicker and more convenient.

 Add the New Language Aspect and Localizable Resources to the Application Model

These are the initial steps that should be performed independent of the chosen localization approach.

  • Localization of the XAF modules and DevExpress controls used in your XAF application is required. If the localized resources are available for the target language, you can use them. Otherwise, you should export the culture-specific resources to the Application Model, to enable the capability to localize them together with your custom text. Follow the recommendations described in theLocalize Standard XAF Modules and DevExpress Controls Used in an Application topic.
  • Localizable resources of Windows Forms Templates are not available in the Application Model by default. To export them, modify the collection exposed by the Windows Forms module‘s ModuleBase.ResourcesExportedToModel property or application‘sXafApplication.ResourcesExportedToModel property. You can use the Module or Application Designer for this purpose, respectively. You should add the "MainForm Template", "DetailViewForm Template", "NestedFrame Template", "LookupControl Template" and "PopupForm Template" items.

    Note

    Template resources include strings such as "File", "View", "Home" and "Tools", used in the application‘s main menus as well as the ribbon. If you see that the menu items in the standard form, or page and group captions in the ribbon form, are not translated, ensure that you have added and translated the template resources.

  • If there are "hardcoded" strings visible in the application UI, it is recommended that you make them localizable. Refer to the How to: Localize Custom String Constants topic for details.
  • Invoke the Model Editor for the module project. Add a new language via the Languages Manager, as described in the Localization Basics topic. Repeat this step for the platform-specific modules. Note that a Visual Studio restart is required to see localized text provided with satellite assemblies in the Model Editor.

 Use the Localization Tool

We recommend that you begin the translation from the platform-agnostic module, and then proceed to the platform-specific modules. Follow the steps below to localize each of your XAF application modules with the Localization Tool.

  • Click the Localization button in the XAF Model Editor Toolbar. The expressApp Framework Localization window will be invoked.

    This window provides the grid editor with all localizable property names, paths, descriptions and values. The toolbar with the set of commands is also provided. The grid columns and actions available in this window are described in the Localization Tool topic.

  • In the Localization window toolbar, select the target language via the Translation Language drop-down.

    Note

    If you have successfully installed satellite assemblies for the target language, you will see that text supplied with the standard XAF modules have already been translated.

  • Apply the Untranslated non-calculated filter via the Filters action.

    This filter selects the properties that have non-empty default language values with Is Translated unchecked and Is Calculatedchecked. For instance, the OwnMembers node’s Caption properties will be displayed and the Columns node’s Caption properties will be hidden.

  • Translate all the values in the Translated Value column. Pressing the ENTER key moves focus to the next row. If there are several properties with the same Default Language value, the Multiple Values Translation dialog will be invoked. Click Yes, and all these values will be translated at once, and the next value to be translated will be focused.

    Note

    • You can use the Translate... button to automate the translation. Select one, several or all rows, and click Translate... or press CTRL+T. In the invoked dialog, select the original language (English by default), click Translate and the Microsoft Translator service will translate for you. Of course, an Internet connection is required for this feature. Note that automatic translation is not perfect, and requires review.
    • If you are not fluent in the target language, you can hire a professional translator. Export the selected rows to a CSV file via the Export |Selected records command, and pass this file to the translator. The translator will edit the values in the Translated Value column using a spreadsheet or a plaintext editor of his/her choice. The Description column content will help him/her see the context. The translated values can be loaded back from the CSV file via the Import Action. If non-latin characters are used in the CSV file, the file encoding should be UTF-8.
  • When you have finished the translation, click Save or press CTRL+S to save changes to the Application Model. The translated properties will be hidden due to the Untranslated... filter, and the Is Translated checkbox is checked after saving.

  • Next, apply the Calculated filter to review the calculated values.

  • After closing the Localization window, you can see the localized values in the Model Editor. Save the changes in the Model Editor.

A typical XAF application has platform-specific versions of the authentication, security strategy and modules. For instance, Windows Forms and ASP.NET applications can have SchedulerWindowsFormsModule and SchedulerAspNetModule modules included respectively. These modules extend the Application Model with localizable properties that are not available at the module level. You can have platform-specific Controllers provide strings that need to be localized (action captions, tooltips, exceptions, etc.). So, you should repeat these steps for each platform-specific module.

 Localize an XAF Application Directly in the Model Editor

Localizing an XAF application directly in the Model Editor is an alternate approach.

    • Select the target language via the XAF Model Editor Toolbar.
    • Set the localized values to the properties of the Application root node.
    • Expand the ActionDesign | Actions node. Set the localized values to the Caption properties of all its child nodes. The ShortCaptionand the Tooltip properties will be localized automatically, as they expose values from the Caption properties by default. Localize theConfirmationMessage properties if required.

Note

If you do not use the Active Directory authentication, take special note of the Log On window (web page) UI elements‘ localization. The Log On andCancel buttons are Actions. These Actions have Logon and DialogCancel IDs, and are localizable under the ActionDesign | Actions node.

    • Expand the ActionDesign | DisableReasons node. Set localized values to the Caption properties of its child nodes.
    • Expand the BOModel node. Set localized values to the Caption properties of its child nodes. You can skip nodes of classes that are not represented in the application UI (e.g., the XPBaseObject node). Note that the localization of ObjectCaptionFormat properties may also be required. The Caption properties of CreatableItemsNavigationItems and Views child nodes will be localized automatically as they expose values from class captions by default.
    • Expand the Localization node. Set localized values to the Value properties of its child nodes. Take special note of the Exceptions |UserVisibleExceptions child node. You can skip the Exceptions | SystemExceptions node, as it contains exceptions addressed to developers and administrators, and is invisible to end-users in normal application operation.
    • Expand the NavigationItems node. Check to see if there are any child nodes with captions not localized automatically. The Defaultnode caption should be localized.
    • If the ValidationModule module is used in the application, expand the Validation node. Set localized values to the child node properties denoted by the globe glyph ().
    • A typical XAF application has platform-specific versions of the authentication, security strategy and modules. For instance, Windows Forms and ASP.NET applications can have SchedulerWindowsFormsModule and SchedulerAspNetModule modules included, respectively. These modules extend the Application Model with localizable properties that are not available at the module level. You can have platform-specific Controllers that provide strings that need to be localized (action captions, tooltips, exceptions, etc.), so repeat these steps for each platform-specific module.
    • If you do not use the Active Directory authentication type, localization of the Log On window (web page) requires special attention. This window (web page) content is represented by the AuthenticationStandardLogonParameters Detail View, so navigate to theViews | AuthenticationStandardLogonParameters_DetailView node and set the localized value to its Caption property. Expand the Items child node and localize the Text property of the LogonText node. Localize the UserName and Passwords node captions.

Note

This step should be performed separately for Windows Forms and ASP.NET applications. Use the Model Editor invoked for each application project to localize the Log On window (web page) UI elements. However, the "Log On" and "Cancel" Actions captions can be localized in the module project Model. See the step 5 note for details. The message displayed when the logon fails is also localized in the module project Model under theLocalization | Exceptions | UserVisibleExceptions | Security node.

  • There are additional Localization child nodes in the Model Editor, invoked for the application project (Windows Forms or ASP.NET). For instance, in the Windows Forms application Model, you should set localized values to ConfirmationsDialogButtons andFrameTemplates child nodes.

 Miscellaneous Localizations that Cannot be Performed at Design Time

  • The splash screen form displayed on the Windows Forms application startup contains the "Loading" text label. This default text is hardcoded in XAF sources, as the Application Model is not yet initialized when the splash is displayed (see Windows Forms Application Creation and Initialization). You can set a different text using the ISplash.SetDisplayText method.


    C#

    VB
     

    static void Main() {
        // ... 
        MySolutionWindowsFormsApplication winApplication =
            new MySolutionWindowsFormsApplication();
        // ... 
        try {
            winApplication.SplashScreen.SetDisplayText("Custom Text");
            winApplication.Setup();
            winApplication.Start();
            // ... 
    

原文地址:https://www.cnblogs.com/xyyhcn/p/11719552.html

时间: 2024-08-26 14:03:45

XAF应用开发教程(八) 汉化与多国语言支持的相关文章

PowerDesigner V16.5 安装教程以及汉化(数据库建模)

一.power designer是什么以及是干什么的? power designer是能进行数据库设计的强大的软件,是一款开发人员常用的数据库建模工具.分别从概念数据模型(Conceptual Data Model)和物理数据模型(Physical Data Model)两个层次对数据库进行设计. 概念数据模型描述的是独立于数据库管理系统(DBMS)的实体定义和实体关系定义: E-R图,在数据库系统概论中有涉及到,这个实体关系图中,一个实体对于一个表,实体.属性与联系是进行系统设计时要考虑的三个

XAF应用开发教程(五)验证模块

数据验证是应用程序开发中使用频率最高的功能模块,本节详细介绍一下XAF中如何使用验证模块. XAF 验证模块内置了下面的一些验证规则: 验证规则类型 说明 RuleCombinationOfPropertiesIsUnique (RuleCombinationOfPropertiesIsUniqueAttribute) 要求多个属性的值组合在一起时是唯一的. RuleCriteria (RuleCriteriaAttribute) 要求满足指定的条件. 如:座机或手机必须填写一个. 条件为:坐机

XAF应用开发教程(四)应用程序模型

https://www.cnblogs.com/foreachlife/p/xafml.html XAF是重量型框架,确实够重量的,方方面面都做得规规矩矩. 如果看了前面三节,可能会认为,这N多的Attribute到底都是从哪里来的?到底有多少这样的Attribute?如果不够用了怎么办?等着官方开发吗? 好吧,我不是为了解决上面的这些问题的,从另一个角度来看一下我们的应用程序吧! 我们回过头来看看解决方案中的项目都是做些什么用途吧: XAF的默认项目结构中,XCRMDemo.Module中写了

Androidstudio2.0.0汉化教程及汉化包。

()Eric为大家带来Androidstudio2.0.0的简单汉化教程,许多小伙伴喜欢使用中文版的AS那么没有中文的AS只能靠自己汉化取得更好的体验. 第一步下载AS2.0.0汉化包,我有链接给大家分享下,点击下载 http://pan.baidu.com/s/1o8BDn8Q 如有资源过期现象请联系qq1489259653   我会第一时间为您解决. 第二部打开汉化包,打开zh_CN 打开后这样子,不要关闭窗口. 现在打开AS的安装路径.是这个样子的,打开lib目录. 下拉找到resourc

XAF应用开发教程(七)外观控制模块

很多时候,我们需要按照不同的条件显示不同的效果,在传统的软件开发中,我们会直接使用 控件名称.BackColor,Enable,Visible等属性进行控制. 如果一个业务对象在多处使用,要么我们会去一个地方一个地方的修改,要么会集中代码做个方法进行控制. 在XAF中,就实现了一处控制全局生效的方法. 下面我们来看看外观模块: 上图中展示了几种效果:1,整行红色背景.2,蓝色字体加删除线.3编辑时控件禁用.4.单元格颜色变化. 详细界面中,同样生效了,上面两幅图,一个是web的,一个winfor

XAF应用开发教程(六)控制器

https://www.cnblogs.com/foreachlife/p/xafviewcontrollerAndValidationContext.html 是的,XAF也是MVC结构的,但不仅限于MVC,ViewModel也存在,它是一项复合技术,AOP,ORM,MVC都有. 真实运行的系统中,仅有增删改查功能肯定是远远不够的,ERP.CRM等系统的开发中,有无数的业务逻辑,通常这些都是在控制器中实现的,控制器有两种: ViewController:应用于视图,需要操作视图的数据. Win

XAF应用开发教程(一) 创建项目

XAF是DevExpress公司的快速开发框架,全称eXpress Application Framework,是企业信息系统的开发利器,快速开发效果显著,在.net框架中,笔者至今没有找到一款可以与之比较的产品.下面以应用为中心,讲述如何应用XAF. 下载与安装,如果你已经安装好了sqlserver和visual studio,请至http://www.devexpress.com 下载试用版,安装完成后即可体验. 我使用的是vs2015+sqlserver 2014(与vs内置一起的). 一

XAF应用开发教程(二)业务对象模型之简单类型属性

https://www.cnblogs.com/foreachlife/p/XAFBOSimpleTypeProperty.html 使用过ORM的朋友对这一部分理解起来会非常快,如果没有请自行补习吧:D. 不说废话,首先,我们来开发一个简单的CRM系统,CRM系统第一个信息当然是客户信息.我们只做个简单 的客户信息来了解一下XAF好了. 新建项之后,可以看到如下代码界面: using System; using System.Linq; using System.Text; using Dev

XAF应用开发教程(三)业务对象模型之引用类型与关联关系

本节介绍信息系统开发中最常见的问题,引用关系,一对多关系,多对多关系. 以客户信息为例,客户通常需要客户分类,如VIP客户,普通客户,潜在客户.当然,我们可以定义枚举类型进行定义出这个类型,并在客户类上面定义对应的属性. 但枚举类型增加值需要修改程序,而客户分类很可能是会增加或是修改的,此时,我们就需要用到了引用类型.引用类型对应到数据库上,也就是外键关系. 既然是需要可以维护的客户分类,那么我们应该建立一张表出来,在XPO中就要新建出一个业务类,代码如下: [DefaultClassOptio