Localized Labels on Custom Widgets

Posted by Community Admin on 05-Aug-2018 16:51

Localized Labels on Custom Widgets

All Replies

Posted by Community Admin on 07-Feb-2011 00:00

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?

Posted by Community Admin on 10-Feb-2011 00:00

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..

Posted by Community Admin on 11-Feb-2011 00:00

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.

Posted by Community Admin on 14-Apr-2011 00:00

Is it possible to use a localization label in a master page? I've been trying with

<asp:Label ID="(Key value)" runat="server" />

Posted by Community Admin on 14-Apr-2011 00:00

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 >>

Posted by Community Admin on 14-Apr-2011 00:00

Cheers! That did the trick, thanks :-)

Posted by Community Admin on 10-May-2011 00:00

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

Posted by Community Admin on 13-May-2011 00:00

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 >>

Posted by Community Admin on 13-Mar-2012 00:00

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

Posted by Community Admin on 13-Mar-2012 00:00

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

Posted by Community Admin on 10-Oct-2013 00:00

Hi Radoslav,
The link under "here." is not working. Can you please provide the correct link?

Thanks
Nirav

Posted by Community Admin on 15-Oct-2013 00:00

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.

This thread is closed