+1-888-365-2779
Try Now
More in this section

Forums / Sitefinity SDK / Localized Labels on Custom Widgets

Localized Labels on Custom Widgets

12 posts, 0 answered
  1. Jeff
    Jeff avatar
    9 posts
    Registered:
    29 Nov 2009
    07 Feb 2011
    Link to this post
    I am trying to use Sitefinity to store and retrieve the localizable labels for my own widgets (user controls).  My goal is for them to be included in Sitefinity's import/export of all localizable content for easy editing offline.

    I have a special method in all my user controls to retrieve labels based on a string key.  I would like to hook this method up to the Sitefinity API to retreive the localized label.

    Is this possible, and if so what approach should I take?  How does the mechanism work?
  2. Jeff
    Jeff avatar
    9 posts
    Registered:
    29 Nov 2009
    10 Feb 2011
    Link to this post

    Would Telerik.Sitefinity.Localization.Data be the right place to start? 

    To be more specific, I can add a localizable label with this code:

    var resources = ResourceManager.GetManager();
    resources.AddItem(
        Thread.CurrentThread.CurrentCulture,
        "GroupName",
        "TestLabel1",
        "TestLabel1 Value",
        "TestLabel1 Description");
    resources.SaveChanges();

    And retrieve it with this code:

    var resources = ResourceManager.GetManager();
    var resource = resources.GetResourceOrEmpty(Thread.CurrentThread.CurrentCulture, "GroupName", "TestLabel1");

    But how do I make it appear in the "Administration > Interface Labels and Messages" section of the Sitefinity back-end so that I can use the import/export language pack feature to set the value of my new label?

    I can see the new ClassID "GroupName" in Type dropdown of the "Create Label" form of the tool, but the label itself doesn't appear in the spreadsheet when I export..
  3. Pavel Iliev
    Pavel Iliev avatar
    140 posts
    Registered:
    18 Jul 2016
    11 Feb 2011
    Link to this post
    Hello Jeff,

    Please, check the Products sample from the SDK.

    You have to inherit from Telerik.Sitefinity.Localization.Resource and then register your resource in Global.asax like that:

    protected void Application_Start(object sender, EventArgs e)
    {
        Bootstrapper.Initialized += newEventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(this.AfterInit);
        }
     
    private void AfterInit(object sender, ExecutedEventArgs args)
    {
        Res.RegisterResource<CustomModuleResources>();
    }

     



    Regards,
    Pavel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Adam
    Adam avatar
    6 posts
    Registered:
    11 Apr 2011
    14 Apr 2011
    Link to this post
    Is it possible to use a localization label in a master page? I've been trying with

    <asp:Label ID="(Key value)" runat="server" />
  5. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    14 Apr 2011
    Link to this post
    Hello Adam,

    You can use localized strings for label texts in master pages and even in .aspx pages part of your Sitefinity project. Bellow is a sample use of how to get the localized text for a resource class:
    <asp:Label runat="server" ID="lbl1" Text='<%$ Resources:NewsResources, Content %>'></asp:Label>


    Greetings,
    Radoslav Georgiev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  6. Adam
    Adam avatar
    6 posts
    Registered:
    11 Apr 2011
    14 Apr 2011
    Link to this post
    Cheers! That did the trick, thanks :-)
  7. freddy
    freddy avatar
    2 posts
    Registered:
    13 Apr 2011
    10 May 2011
    Link to this post
    dear , i have a question but please reply me asap :) , i made 8 users controls and registered them as widgets , but  i am using Global resources of Asp.net ( .resx ) files , and my controls cant see these resources ... my version is 4.1 , please reply me asap , cause we are delivering ...

    Thanks;
    Freddy Khalaf
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 May 2011
    Link to this post
    Hello freddy,

    The thing is that we do not use the ASP.NET resource provider. We are using a custom one. You need to use localization strings as described here.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  9. Swati
    Swati avatar
    9 posts
    Registered:
    19 Apr 2011
    13 Mar 2012
    Link to this post
    Hi Sitefinity Team,
    Can we import ASP.NET resource file in 'Import language pack' under 'Interface Labels and Messages' section of Administration? So that editor can edit resource key/values according to language. If yes, please provide details. It'll be very helpful in maintaining labels for custom controls.
    Thanks,
    Swati Bhatia
  10. Swati
    Swati avatar
    9 posts
    Registered:
    19 Apr 2011
    13 Mar 2012
    Link to this post
    Hi Sitefinity Team,
    Can we import ASP.NET resource file in 'Import language pack' under 'Interface Labels and Messages' section of Administration? So that editor can edit resource key/values according to language. If yes, please provide details. It'll be very helpful in maintaining labels for custom controls.
    Thanks,
    Swati Bhatia
  11. nblack
    nblack avatar
    1 posts
    Registered:
    09 Mar 2012
    10 Oct 2013 in reply to Radoslav Georgiev
    Link to this post
    Hi Radoslav,
    The link under "here." is not working. Can you please provide the correct link?

    Thanks
    Nirav
  12. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    06 Dec 2016
    15 Oct 2013
    Link to this post
    Hello,

    Please review the article available in our Sitefinity documentation.  Furthermore, you could take a look at this forum thread.

    Regards,
    Stefani Tacheva
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

12 posts, 0 answered