Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Asembli 86 posts 260 karma points
    Apr 16, 2024 @ 07:27
    Asembli
    0

    Custom propery converter and input parameter 'culture'

    Does anyone have an example of how to read culture as parameter or, for example, default value as parameter in the custom property converter (IPropertyValueConverter)? Because when I look at the instructions, I can't find anything tangible. To sum up:

    • I have a custom datatype, for example string, to make it easier
    • then I make 'my' property converter (IPropertyValueConverter) where I want to format the value in my own way - this was rather simple
    • then I would like to send to property converter (from current culture 'en') another language, say 'de', and then concatenate mapped value with this value
    // let say that value for data type 'whatever' is 'test'
    // current culture is 'en'
    
    string x = Model.Content.Value<string>("whatewer")
    
    // should return 'test'
    
    x = Model.Content.Value<string>("whatewer", "de")
    
    // should return 'test-de'
    

    (Of course I'have more complex task for solve, above 'concatenating' is just for example)

    What do I have to override in the property converter to get culture = 'de' inside.

    this gives current culture 'en'

    var currentCulture = this.variationContextAccessor.VariationContext.Culture;
    

    I want 'de' instead

    Regards

Please Sign in or register to post replies

Write your reply to:

Draft