Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 383 posts 1280 karma points
    Jun 05, 2017 @ 09:35
    Adriano Fabri
    0

    Localize with params

    Hi to all,

    there is a way to use param with localized key?

    Example:

    (test.html)
    
    <localize key="MyPlugin_TestWithParam" >Test with param</localize>
    
    ---------------
    
    (it-IT.xml)
    
    <key alias="TestWithParam"><![CDATA[Test con un parametro]]></key>
    

    Now I need to add a param in the localized CDATA text like this (or similar):

    <key alias="TestWithParam"><![CDATA[Test con un parametro {0}]]></key>
    
    • Is this the right way to set a parameter ({0}) inside language resource file?
    • How do I change the <localize> html tag to valorize the {0} field?

    Thanks

  • Delete 61 posts 449 karma points
    Jun 05, 2017 @ 12:27
    Delete
    0

    Hi Adriano,

    So, you have a few ways:

    1. In a view you can write as:

    @(string.Format(umbraco.GetDictionaryValue("[key]"), [params]))

    1. You can write Html extension which will be take key and params, and this method will return correct value.

    Regards, Vitaly

  • Adriano Fabri 383 posts 1280 karma points
    Jun 06, 2017 @ 12:27
    Adriano Fabri
    0

    Thank you Vitaly, but I would to do it with the

    Do you know if there is a way to do that?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies