如何查找内置SharePoint列表名称的区域翻译?

时间:2010-08-20 11:35:35

标签: .net sharepoint sharepoint-2007 translation

PublishingWeb.PagesListPublishingWeb.PagesListName个属性,但其他列表的网址也因网站语言而异。我发现的翻译是:

  • 文档
  • 图片
  • 工作流程任务

SP2010中还有其他API,但我如何在2007年处理此问题?

1 个答案:

答案 0 :(得分:0)

此数据可通过内部方法获得。所以我有一个invoke helper方法:

[NotNull]
public static T Call<T>([CanBeNull] ref T cachedInvoker, [NotNull] Type subject, [NotNull] string methodName) where T : class
{
    if (cachedInvoker == null)
    {
        var method = subject.GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic);
        cachedInvoker = Delegate.CreateDelegate(typeof(T), method) as T;
        if (cachedInvoker == null)
            throw new ApplicationException(string.Format("Unable to create invoker for [{0}].[{1}].", subject, methodName));
    }
    return cachedInvoker;
}

然后我得到了数据:

[NotNull]
public static SPFolder Documents([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetDocumentsListId()].RootFolder;
}

[NotNull]
public static string GetDocumentsListName([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetDocumentsListId()].Title;
}

private static Func<PublishingWeb, Guid> getDocumentsListIdInvoker;

[NotNull]
public static Guid GetDocumentsListId([NotNull] this PublishingWeb web)
{
    return
        Internal.Call(ref getDocumentsListIdInvoker, typeof (PublishingWeb), 
            "get_DocumentsListId")(web);
}

[NotNull]
public static string GetImagesListName([NotNull] this PublishingWeb web)
{
    return web.Lists[web.GetImagesListId()].Title;
}

private static Func<PublishingWeb, Guid> getImagesListIdInvoker;

[NotNull]
public static Guid GetImagesListId([NotNull] this PublishingWeb web)
{
    return
        Internal.Call(ref getImagesListIdInvoker, typeof(PublishingWeb), 
        "get_ImagesListId")(web);
}