Ticket Q302639
Visible to All Users

Localization of data property values based on external tables

created 14 years ago

hi.
we have persistent objects that have a property "Label".
we would like to be able to "localize" these values, that is to say:
- the customer creates one of these objects
- then, he must be able to enter different values for different language
- later, in another app, the label property must be loaded according to a chosen language.
we consider 2 approaches:
- via custom classinfo, adding custom column "LabelFR", "LabelDE", etc…
- via xpcollection, that would link a key and its localizations
would you mind give us your feelings about these 2 ways, and / or suggest other solutions?
thanks

Answers

created 14 years ago (modified 10 years ago)

Hi Michel,
I should say that XAF does not support this functionality internally, and in my opinion, this task is not specifically related to the XPO library. On a side note, I would prefer to have a separate table (a persistent class) for localized strings, and reference properties to this class for all localizable string properties in my project. For example:

C#
[DefaultProperty("Value")] public class LocalizableString : XPObject { public LocalizableString(Session s) : base(s) { } [Association("LocalizedStrings")] public XPCollection<StringLocalization> Values { get { return GetCollection<StringLocalization>("Values"); } } [PersistentAlias("iif(Values[Culture=CurrentUICulture()], Values[Culture=CurrentUICulture()].Max(Value), Values[IsNullOrEmpty(Culture)].Max(Value))")] public string Value { get { return Convert.ToString(EvaluateAlias("Value")); } } } public class StringLocalization : XPObject { public StringLocalization(Session s) : base(s) { } public string Value; [Indexed("Item", Unique = true)] public string Culture; [Association("LocalizedStrings")] public LocalizableString Item; } [NavigationItem] public class Class1 : XPObject { public Class1(Session s) : base(s) { } public LocalizableString PropertyA; public LocalizableString PropertyB; public LocalizableString PropertyC; } // Register this function by calling the CriteriaOperator.RegisterCustomFunction method public class CurrentUICultureFinction : ICustomFunctionOperatorFormattable { public string Format(Type providerType, params string[] operands) { return string.Concat("'", System.Globalization.CultureInfo.CurrentUICulture.Name, "'"); } public object Evaluate(params object[] operands) { return System.Globalization.CultureInfo.CurrentUICulture.Name; } public string Name { get { return "CurrentUICulture"; } } public Type ResultType(params Type[] operands) { return typeof(string); } }
    Show previous comments (4)
    ST ST
    Stanislaw Tristan 10 years ago

      @Michael: my primary business requirement is to using the server mode on the all list views, as I know XPView/DataView does not support server mode? Can I ask you about implementing this support in the nearest version?

      DevExpress Support Team 10 years ago

        @Stanislaw: Implementing a new server mode source component based on XPView is not a simple task and we don't have immediate plans to do this. Anyway, thank you for your suggestion. Note that a similar scenario was also discussed in the S36566 ticket. You can add it to your favorites to be notified when anything changes.

        Anatol (DevExpress) 10 years ago

          A ticket about the solution with PersistentAlias in Server Mode: How to return property name from ICustomFunctionOperatorFormattable.Format method?

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.