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

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

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

要实现汉化很简单:

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

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

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

这一步的功能是:汉化多数控件中的使用的文字资源。这是官方提供的方法,也有些字符串是没有被汉化的。因为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.

 

XAF应用开发教程(八) 汉化与多国语言支持 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.
 

XAF应用开发教程(八) 汉化与多国语言支持 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.

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

    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.

    XAF应用开发教程(八) 汉化与多国语言支持
    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.

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

    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.

    XAF应用开发教程(八) 汉化与多国语言支持
    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.

    XAF应用开发教程(八) 汉化与多国语言支持
  • Next, apply the Calculated filter to review the calculated values.

    XAF应用开发教程(八) 汉化与多国语言支持
  • 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.

 

XAF应用开发教程(八) 汉化与多国语言支持 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 (XAF应用开发教程(八) 汉化与多国语言支持).
    • 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.
 

XAF应用开发教程(八) 汉化与多国语言支持 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();
            // ... 
    

如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。 作者博客: http://www.cnblogs.com/foreachlife 欢迎加入XAF技术交流群讨论 XAF技术应用 336090194, QQ:4603528
转载请注明出处。多谢! 欢迎加我微信: admiralcn 或扫码:
XAF应用开发教程(八) 汉化与多国语言支持
 
 
XAF点滴:很具体很用实用---处理三个小问题

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

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

要实现汉化很简单:

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

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

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

这一步的功能是:汉化多数控件中的使用的文字资源。这是官方提供的方法,也有些字符串是没有被汉化的。因为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.

 

XAF应用开发教程(八) 汉化与多国语言支持 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.
 

XAF应用开发教程(八) 汉化与多国语言支持 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.

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

    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.

    XAF应用开发教程(八) 汉化与多国语言支持
    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.

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

    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.

    XAF应用开发教程(八) 汉化与多国语言支持
    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.

    XAF应用开发教程(八) 汉化与多国语言支持
  • Next, apply the Calculated filter to review the calculated values.

    XAF应用开发教程(八) 汉化与多国语言支持
  • 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.

 

XAF应用开发教程(八) 汉化与多国语言支持 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 (XAF应用开发教程(八) 汉化与多国语言支持).
    • 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.
 

XAF应用开发教程(八) 汉化与多国语言支持 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();
            // ...