The development of sharepoint is faster and faster,now many companies have started to use Sharepoint in many countries. If you work in one multinational company, when you develop sharepoint, you should pay attention to multilingual problems.Here to share one example about how to develop the multi-language UI(User Interface).
1. Create one empty sharepoint project, and then create 2 Resource files:
SPDemo.resx;
SPDemo.es-US.resx;
You could name any names for these files, but you should take care the language suffix.(e.g. zh-CN is China, and es-US is United States).
you should add some values for these Reource files:
SP_Demo_Order_Amount Order Amount
SP_Demo_Order_Name Order Name
SP_Demo_Order_Price Order Price
2. Create one Application page, and add some Labels and 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>
3. Ensure the Resource files are deployed to SharePoint Root/14/Resources
4. Add the behind code:
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);
}
}
}
Note: the use of method: GetLocalizedString(Source, Resource,language): Get the corresponds Resource files’ sting values based on the Language value. For example:If current language is US English, the SPDemo_US.resx will be found.
5. After deployment, you will get the effect.