zoukankan      html  css  js  c++  java
  • SharePoint中的本地化(Localization)

    I. 对于SharePoint 2010,本人实践过的有效方法有如下两种:

    1. 在公用DLL文件中创建“MyResources.resx”文件,并通过如下语法引用:
    在ASPX文件中:
    Text="<%$Resources:MyResources,MyStringA%>"

    2. 在SharePoint资源文件夹“$SharePointRoot\Resources”下创建资源文件“MyResources.resx”,并通过如下语法引用:
    在XML文件中:
    <Field Name="TypeShortDescription">$Resources:MyResources,MyStringA;</Field>

    注:
    1. 方法1仅对ASPX文件有效,但对XML文件无效;方法2仅对XML文件有效,但对ASPX文件无效。
    2. 对于方法2,若将资源文件部署到“$SharePointRoot\Config\Resources”下,资源引用对ASPX和XML文件均无效。

    II. 如下是更全面的本地化方法介绍,但没有实践验证过:

    SharePoint & Resources

    First thing you need to know, SharePoint defines two kinds of Resource files: Application resources and Provisioning resources. Application resources are resources used within the normal execution of the SharePoint application. Normal SharePoint execution include: Application Pages, Web Parts and Controls. SharePoint also makes a difference between application resources used in normal web applications and application resources used in the central administration. Don’t forget that. Provisioning resources, on the other hand, are used when provisioning elements, so you have to use them within features, site definitions and list definitions. Ok, now let’s see the practical side of it: deployment and usage.

    1. Deployment

    Resource files in SharePoint are located in different folders. Here is a list:

    • C:\Inetpub\wwwroot\wss\VirtualDirectories\<port>\App_GlobalResources\
    • <hive>\12\Resources\
    • <hive>\12\CONFIG\Resources\
    • <hive>\12\CONFIG\AdminResources\
    • <hive>\12\TEMPLATE\FEATURES\<feature>\Resources\

    So, how do you know where to put your resource files? Well, every type of resource has its own folders.

    Provisioning resources

    • <hive>\12\TEMPLATE\FEATURES\<feature>\Resources\Resources.<culture>.resx
    • <hive>\12\TEMPLATE\FEATURES\<feature>\Resources\
    • <hive>\12\Resources\

    Every feature uses the resources file located in its Resources folder. You can however use another resource file or even share resources. To share resource files you have to put them in the 12\Resources\ folder. Site definitions and list definitions also get their resources from this folder.

    Application resources

    • <hive>\12\CONFIG\Resources\
    • C:\Inetpub\wwwroot\wss\VirtualDirectories\<port>\App_GlobalResources\

    Application resources are located in CONFIG\Resources folder. For a web application to use those resources, they have to be copied to their App_GlobalResources folder. (each web application has its own Global Resources folder) How is this done? At creation of the web application, the resources are initially copied to the App_GlobalResources folder. When adding new resources to the CONFIG\Resources folder, the resources have to be copied to existing web applications. You can do this manually or use the STSADM command: copyappbincontent.

    Application resources: admin

    • <hive>\12\CONFIG\AdminResources\
    • C:\Inetpub\wwwroot\wss\VirtualDirectories\<port>\App_GlobalResources\

    Application resources for the central administration work the same way as normal application resources, except that the base folder is CONFIG\AdminResources.

    2. Usage

    This last part will focus on how to use resources within SharePoint elements. Luckily it doesn’t really matter which kind of resource you are using. Here are the different ways:

    In C#:
    HttpContext.GetGlobalResourceObject("MyResource", "MyName").ToString();

    In ASPX properties:
    <%$Resources:MyResource, MyName%>

    In ASPX as text:
    <asp:literal runat="server" Text="<%$Resources:MyResource, MyName%>" />

    In XML:
    $Resources:MyResource, MyName

    In XML features, using the default resource file:
    $Resources:MyName

    3. Conclusion

    There you go. Everything you will ever want to know about resources in SharePoint.

    Part of this article is derived from the excellent article of Mikhail Dikov. You can consider this article as some sort of extension of his article. Be sure to read it. Also, I’d like to thank Tom Verhelst for the heads up on the copyappbincontent. Thanks man!

    Reference source: http://tomblog.insomniacminds.com/2008/02/25/sharepoint-internals-resources/

  • 相关阅读:
    C#控件随窗体大小改变而改变
    Java泛型
    php的stristr()函数,查找字符
    java设计模式之桥梁模式(Bridge)
    怎样从本地删除git远程仓库里面的文件
    VS code 修改主题设置代码对其齐线
    vue+webpack安装sass过程中遇到权限不够,直接删除node_modus文件夹重新安装,node_modus先取得管理员权限才能删
    转:git合并冲突解决方法
    git命令行解决冲突文件步骤
    dos常用命令
  • 原文地址:https://www.cnblogs.com/jancco/p/2489122.html
Copyright © 2011-2022 走看看