none
Feature Title and description from "Resources" files

    Question

  • Is it possible to Read the features titles and descriptions from Resources files ?

    We need the titles and descriptions to be language specific because we are creating something like a language pack for a service that we offer based on sharepoint.
    Monday, April 13, 2009 2:22 PM

Answers

  • hello sachin,

    Yes, definetly you can do that.
    One advice to you is always use the default sharepoint installation files located at 12 hive for your learning experience.

    Open the custom list feature file (12\Template\Features\CustomList\Feature.xml ) , you'll find the following :

    <Feature Id="00BFEA71-DE22-43B2-A848-C05709900100"
        Title="$Resources:core,customlistFeatureTitle;"
        Description="$Resources:core,customlistFeatureDesc;"
        Version="1.0.0.0"
        Scope="Web"
        Hidden="TRUE"
        DefaultResourceFile="core"
        xmlns="http://schemas.microsoft.com/sharepoint/">

    Title="$Resources:core,customlistFeatureTitle;". $Resources denotes that we will use a resource reference rather than a regular hard-coded string, core is the the resource file name (core.resx), and customlistFeatureTitle is the key name to use. If you include a DefaultResourceFile attribute to the feature element, you don't need to include the file name part (you can use $Resources:customlistFeatureTitle; directly ).

    There is another way if you don't want to add keys to SharePoint Resources files which is :
    1) Create a folder called "Resources" into your feature folder
    2) Create a resx file called Resources.resx inside the newly created folder.
    3) Add whatever keys you want inside the file.
    4) Set DefaultResourceFile to "_RES" to be able to remove the file name part of the resource name.
    5) If you want to obtain a value for Title key --> use $Resources:featuretitle;

    This is much better than adding keys and values to the default sharepoint files because a service pack installation might overwrite all your keys..

    let me know if you need any help.


    Ayman M. El-Hattab, Microsoft Certified SharePoint Specialist, http://ayman-elhattab.blogspot.com .. Follow me at twitter @ http://twitter.com/aymanelhattab
    • Marked as answer by Sachin Piktar Monday, April 13, 2009 3:21 PM
    Monday, April 13, 2009 3:08 PM

All replies

  • hello sachin,

    Yes, definetly you can do that.
    One advice to you is always use the default sharepoint installation files located at 12 hive for your learning experience.

    Open the custom list feature file (12\Template\Features\CustomList\Feature.xml ) , you'll find the following :

    <Feature Id="00BFEA71-DE22-43B2-A848-C05709900100"
        Title="$Resources:core,customlistFeatureTitle;"
        Description="$Resources:core,customlistFeatureDesc;"
        Version="1.0.0.0"
        Scope="Web"
        Hidden="TRUE"
        DefaultResourceFile="core"
        xmlns="http://schemas.microsoft.com/sharepoint/">

    Title="$Resources:core,customlistFeatureTitle;". $Resources denotes that we will use a resource reference rather than a regular hard-coded string, core is the the resource file name (core.resx), and customlistFeatureTitle is the key name to use. If you include a DefaultResourceFile attribute to the feature element, you don't need to include the file name part (you can use $Resources:customlistFeatureTitle; directly ).

    There is another way if you don't want to add keys to SharePoint Resources files which is :
    1) Create a folder called "Resources" into your feature folder
    2) Create a resx file called Resources.resx inside the newly created folder.
    3) Add whatever keys you want inside the file.
    4) Set DefaultResourceFile to "_RES" to be able to remove the file name part of the resource name.
    5) If you want to obtain a value for Title key --> use $Resources:featuretitle;

    This is much better than adding keys and values to the default sharepoint files because a service pack installation might overwrite all your keys..

    let me know if you need any help.


    Ayman M. El-Hattab, Microsoft Certified SharePoint Specialist, http://ayman-elhattab.blogspot.com .. Follow me at twitter @ http://twitter.com/aymanelhattab
    • Marked as answer by Sachin Piktar Monday, April 13, 2009 3:21 PM
    Monday, April 13, 2009 3:08 PM
  • perfect answer :)
    I've been following your blog for a while . Thanks man
    Monday, April 13, 2009 3:21 PM