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:

  1. In Visual Studio, open the context menu of your project (for example the DayOfWeekPersonalization project for this tutorial) and click Add » New Item..
  2. In the left pane, select Visual C# » Class
  3. Name the class file CustomPersonalizationResources.cs and click Add.
  4. Make the CustomPersonalizationResources class inherit the Resource class.
  5. Mark the class with the ObjectInfo attribute.
  6. Define the constructor of the class.
  7. 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.
New to Sitefinity?