Search This Blog

Thursday, April 24, 2014

About localizing field captions and other strings via the wizard provided by the PivotGrid and Chart controls

I wanted to draw your attention to this feature request, which I have just commented on in the Support Center:

Localizing field captions
By default, the pivot grid and chart controls provided by XAF List Editors take captions for their fields from respective class members defined in the Application Model. Thus, captions for fields specified in the wizard at both runtime or design-time are ignored - they are overridden by the values taken from the Application Model. That said, the recommended approach to localize these fields is to localize the Caption property value of a required class member (under the BOModel | ModelClass | ModelMember node in the Model Editor).

There is one exception for unbound fields in the pivot grid control, whose caption can still be localized in the wizard, because such fields are not processed by the XAF code. So, you can leverage this feature to localize bound field captions, if you want. To do this, you can remove all standard bound fields and instead add new fields with the following characteristics set in the property grid:
    Caption = AnyCaptionYouLike
    FieldName= AnyUniqueFieldName
    UnboundExpression = BoundFieldNameOrAnyValidExpression
    UnboundType = CorrespondingBoundFieldOrExpressionResultType

Alternatively, it is always possible to implement a ViewController that will access a required ListEditor directly and customize its underlying pivot grid or chart controls every time they are shown in the UI. The idea is to use control-specific solutions to implement this task exactly as you would do in a regular non-XAF application. For more information on this, refer to the Access Grid Control Properties and List Editors help articles as well as the documentation on the XtraPivotGrid and XtraCharts Suites. If you have questions on these control-specific solutions, please create tickets for the corresponding control/product in the Support Center so we can assist you further.
While the last two options (via wizard and Controllers) for localizing field captions are technically possible, they look redundant, because they mean duplicating work for an XAF developer. The Application Model is the default and recommended place to localize almost everything in an XAF application, including but not limited to, list and detail forms, reports, etc. - there you perform a localization of a field caption once and this localized value is used everywhere for the most standard XAF modules. The use of wizards and Controllers is only justified in rare cases when captions are not exposed in the Application Model by default.
If you still need to have the capability to localize field captions via the control wizard in an XAF app, please let us know in comments why you need to duplicate this work, because we may be missing some helpful scenarios. Thanks.

Localizing values of enumeration fields
Refer to the Localization - Use localized enumeration values from the Application Model for every visual control integrated in XAF ticket for more details.

Localizing custom control-specific texts unrelated to data fields (like chart titles and legend)

Refer to the Localization - Make it possible to have chart and pivot grid settings based on a specified culture ticket for more details.

In particular, I am interested in scenarios related to localizing BO member captions via the wizard, because this capability looks redundant, as I highlighted above. Thank you for your thoughts on this in advance.
BTW, I also want to mention a small improvement related to localizing custom control-specific texts unrelated to data fields (like chart titles and legend). I hope you find it helpful.

No comments:

Post a Comment