blog.scoreman.net

Archive for January, 2009

Using MOSS internal resources

Thursday, January 29th, 2009

Sometimes you may want to use standard MOSS resource strings that are not found in .resx files in the 12-hive or wwwroot. These strings can reside as compiled resources inside the SharePoint assemblies. Here are two helper functions to extract those resource strings.

private static string publishingAssemblyString = "Microsoft.SharePoint.Publishing.intl, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";
private static string officeServerAssemblyString = "Microsoft.Office.Server.intl, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c";

public static string GetPublishingResource(CultureInfo info, string key)
{
    Assembly assembly = Assembly.Load(publishingAssemblyString);
    ResourceManager rm = new ResourceManager("Microsoft.SharePoint.Publishing.Strings", assembly);
    return rm.GetString(key, info);
}

public static string GetOfficeServerResource(CultureInfo info, string key)
{
    Assembly assembly = Assembly.Load(officeServerAssemblyString);
    ResourceManager rm = new ResourceManager("Microsoft.Office.Server.Strings", assembly);
    return rm.GetString(key, info);
}