• SharePoint 2010 开发多语言用户界面


    SharePoint 的发展越来越快, 现在很多中国的企业也用起了SharePoint, 如果是跨国公司, 这是在开发SharePoint的时候, 就要注意多语言的问题, 这里简单分享下如果实现多语言的用户界面.

    1. 创建一个空SharePoint 项目,创建2个Resources file.

    SPDemo.resx

    SPDemo.zh-CN.resx

    Resources 文件的名字可以随便命名,但是要注意后面的语言的后缀 (zh-CN代表中国, es-US代表美国……)

    简单给Resource文件添加一些值:

                    SP_Demo_Order_Amount

    订单数量

                    SP_Demo_Order_Name

    订单名称

                    SP_Demo_Order_Price

    订单价格

    1. 创建一个Application 页面,直接创建一个Application Page,并添加一些Label 和TextBox.
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Order.aspx.cs" Inherits="MultiLanInterface.Layouts.MultiLanInterface.Order" DynamicMasterPageFile="~masterurl/default.master" %>
    
    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    
    </asp:Content>
    
    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    
       <div>
            <table>
                <tr>
                    <td>
                        <asp:Label ID="lblOrderName" Text="" runat="server"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtOrderName" runat="server"></asp:TextBox>
                    </td>
                </tr>
               </table>
        </div>
    </asp:Content>
    
    <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
    Application Page
    </asp:Content>
    
    <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
    My Application Page
    </asp:Content>
    

    2. 确保Resources 文件部署到SharePoint Root/14/Resources/

    3. 添加后台代码

    using System;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    
    using Microsoft.SharePoint.Utilities;
    namespace MultiLanInterface.Layouts.MultiLanInterface
    {
        public partial class Order : LayoutsPageBase
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                InitControls();
            }
    
            void InitControls()
            {
                lblOrderName.Text = SPUtility.GetLocalizedString("$Resources:SPDemo,SP_Demo_Order_Name", "$Resources:SPDemo", SPContext.Current.Web.Language);
            }
        }
    }
    
      

    备注: GetLocalizedString(Source, Resource,language)方法的用法:根据Language值找到跟语言相对应的Resource文件的string值. 比如当前语言是汉语的话,就会找到SPdemo.zh-CN.resx文件.

    4. 部署后查看页面就能看到效果了

  • 相关阅读:
    获取网页数据
    追踪公式引用的单元格
    loadRunner函数之lr_set_debug_message
    Python爬虫之抓取豆瓣影评数据
    Python爬虫之抓图
    loadRunner函数之web_add_header
    JVM是如何处理异常的
    1. JVM内存区块
    JVM-JVM是如何执行方法调用的
    JVM-内部类分析
  • 原文地址:https://www.cnblogs.com/splover/p/2038604.html
Copyright © 2020-2023  润新知