Create the localizable resource
After you reference the required assemblies, you create the localizable resources. Every module can have a list of localizable resources. In Sitefinity CMS, you wrap the resources in a class that inherits the Resource base class.
To create the resources class for the custom personalization:
- In Visual Studio, open the context menu of your project (for example the DayOfWeekPersonalization project for this tutorial) and click Add » New Item..
- In the left pane, select Visual C# » Class
- Name the class file
CustomPersonalizationResources.csand click Add. - Make the
CustomPersonalizationResourcesclass inherit theResourceclass. - Mark the class with the
ObjectInfoattribute. - Define the constructor of the class.
- Add the resource entries to the class.
You create localizable resource entries, which will be used as field and title values in a later step of this tutorial.
Use the following sample code:
C#
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Localization.Data;
namespace SitefinityWebApp
{
[ObjectInfo(typeof(CustomPersonalizationResources), Title = "CustomPersonalizationResources", Description = "CustomPersonalizationResourcesDescription")]
public class CustomPersonalizationResources : Resource
{
#region Construction
public CustomPersonalizationResources()
{
}
#endregion
#region Class Description
[ResourceEntry("Day",
Value = "Day",
Description = "The day of the week that will apply for this criterion.",
LastModified = "2014/05/23")]
public string Day
{
get { return this["Day"]; }
}
[ResourceEntry("DayError",
Value = "Invalid Day",
Description = "Error message when user enters invalid day.",
LastModified = "2014/05/23")]
public string DayError
{
get { return this["DayError"]; }
}
[ResourceEntry("Monday",
Value = "Monday",
Description = "The day of the week after Sunday but before Tuesday.",
LastModified = "2014/05/27")]
public string Monday
{
get { return this["Monday"]; }
}
[ResourceEntry("Tuesday",
Value = "Tuesday",
Description = "The day of the week after Monday but before Wednesday.",
LastModified = "2014/05/27")]
public string Tuesday
{
get { return this["Tuesday"]; }
}
[ResourceEntry("Wednesday",
Value = "Wednesday",
Description = "The day of the week after Tuesday but before Thursday.",
LastModified = "2014/05/27")]
public string Wednesday
{
get { return this["Wednesday"]; }
}
[ResourceEntry("Thursday",
Value = "Thursday",
Description = "The day of the week after Wednesday but before Friday.",
LastModified = "2014/05/27")]
public string Thursday
{
get { return this["Thursday"]; }
}
[ResourceEntry("Friday",
Value = "Friday",
Description = "The day of the week after Thursday but before Saturday.",
LastModified = "2014/05/27")]
public string Friday
{
get { return this["Friday"]; }
}
[ResourceEntry("Saturday",
Value = "Saturday",
Description = "The day of the week after Friday but before Sunday.",
LastModified = "2014/05/27")]
public string Saturday
{
get { return this["Saturday"]; }
}
[ResourceEntry("Sunday",
Value = "Sunday",
Description = "The day of the week after Saturday but before Monday.",
LastModified = "2014/05/27")]
public string Sunday
{
get { return this["Sunday"]; }
}
#endregion
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
Foundations of Sitefinity ASP.NET Core Development
The free on-demand video course teaches developers how to use Sitefinity ASP.NET Core and take advantage of its decoupled architecture and modern development model.