博客地址:http://blog.csdn.net/FoxDave

上一节讲了SharePoint Online网站多语言的实现原理机制,本节主要从编程的角度来谈一下如何进行相关的设置。
下面列出的代码函数方法在命令行中运行即可。至于Context如何获取可以参考我以前的blog。

Site和List级别的国际化
首先咱们先创建一个测试List,如下代码:
private static void CreateCustomList(ClientContext ctx, Web web)
{
ListCollection listCollection = ctx.Web.Lists;
ctx.Load(listCollection, lists => lists.Include(list => list.Title).
Where(list => list.Title == "LocalizeMe"));
ctx.ExecuteQuery();
// Create the list, if it's not there...
if (listCollection.Count == 0)
{
ListCreationInformation newList = new ListCreationInformation();
newList.Title = "LocalizeMe";
newList.QuickLaunchOption = QuickLaunchOptions.On;
newList.TemplateType = (int)ListTemplateType.GenericList;
newList.Description = "LocalizeMe sample list";
List list = web.Lists.Add(newList);
ctx.ExecuteQuery();
}
}
上面的代码很简单,不做过多解释了,就是创建一个名为LocalizeMe的List。
接下来的代码演示了如何设置多语言的属性。

private static void LocalizeSiteAndList(ClientContext cc, Web web)
{
// Localize site title
web.TitleResource.SetValueForUICulture("en-US", "Localize Me");
web.TitleResource.SetValueForUICulture("fi-FI", "Kielikäännä minut");
web.TitleResource.SetValueForUICulture("fr-FR", "Localize Me to French");
// Site description
web.DescriptionResource.SetValueForUICulture("en-US",
"Localize Me site sample");
web.DescriptionResource.SetValueForUICulture("fi-FI",
"Kielikäännetty saitti");
web.DescriptionResource.SetValueForUICulture("fr-FR",
"Localize to French in description");
web.Update();
cc.ExecuteQuery(); // Localize custom list which was created previously
List list = cc.Web.Lists.GetByTitle("LocalizeMe");
cc.Load(list);
cc.ExecuteQuery();
list.TitleResource.SetValueForUICulture("en-US", "Localize Me");
list.TitleResource.SetValueForUICulture("fi-FI", "Kielikäännä minut");
list.TitleResource.SetValueForUICulture("fr-FR", "French text for title");
// Description
list.DescriptionResource.SetValueForUICulture("en-US",
"This is localization CSOM usage example list.");
list.DescriptionResource.SetValueForUICulture("fi-FI",
"Tämä esimerkki näyttää miten voit kielikääntää listoja.");
list.DescriptionResource.SetValueForUICulture("fr-FR",
"I have no idea how to translate this to French.");
list.Update();
cc.ExecuteQuery();
}

简单说明一下,对于需要国际化的内容,我们需要获取对应的SharePoint Object之后,操作相应的XXResource属性,如上所示,对Site和List的Title和Description进行了国际化。

执行完代码之后,根据当前用户的prefer language,就可以显示不同的语言了。

SharePoint online Multilingual support - Development(1)的更多相关文章

  1. SharePoint online Multilingual support - Development(2)

    博客地址:http://blog.csdn.net/FoxDave 上一节讲了如何通过Code的方式设置Site和List级别的国际化,本节介绍一下如何设置Content type和Site co ...

  2. SharePoint online Multilingual support - Settings

    博客地址:http://blog.csdn.net/FoxDave This post will talk about how to enable sharepoint online site mul ...

  3. Multi-lingual Support

    Multi-lingual Support One problem with dealing with non-Latin characters programmatically is that, f ...

  4. SharePoint Security and Permission System Overview

    转:http://www.sharepointblues.com/2010/09/01/sharepoint-security-and-permission-system-overview/ Shar ...

  5. 10 Skills Every SharePoint Developer Needs

    10 Skills Every SharePoint Developer Needs(原文) This blog post guides you through the essential skill ...

  6. SharePoint 2013 搜索功能,列表项目不能完全被索引

    描述 最近一个站点,需要开启搜索功能,然后创建内容源,开始爬网,发现列表里只有一部分被索引,很多项目没有被索引,甚是奇怪,如下图(其实列表里有80几条项目). 首先爬网账号是系统账号.服务器管理员,所 ...

  7. Device Channels in SharePoint 2013

    [FROM:http://blog.mastykarz.nl/device-channels-sharepoint-2013/] One of the new features of SharePoi ...

  8. INCOIN Importing Multilingual Items (Doc ID 278126.1)

    APPLIES TO: Oracle Inventory Management - Version: 11.5.9 to 11.5.10.CU2 - Release: 11.5 to 11.5 GOA ...

  9. [IT学习]微软如何做网站内容治理

    How Microsoft does SharePoint Governance for their internal platform english sources from:http://www ...

随机推荐

  1. Linux上rsync配置

    一.服务器端配置1.rsyncd.conf文件说明uid = rsync     #用户,用来控制用户访问模块目录的读写权限gid = rsync     #组,用来控制组访问模块目录的读写权限use ...

  2. 微信小程序发起微信支付

    点击链接查看详情:(支付中配置参数需要从后台得到->签名需要从微信申请才可以得到) https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-pay.h ...

  3. css之transform属性

    定义元素的旋转(rotate),缩放(scale),移动(translate),倾斜(skew) rotate rotate(angle) 定义 2D 旋转,在参数中规定角度. rotate3d(x, ...

  4. 2.3 UML活动图

    活动图定义 活动图描述了在一个过程中,顺序的/并行的活动及其之间的关系 应用于商业过程.工作流(业务过程).复杂算法的建模 活动图是顶点和弧的集合 活动节点 动作 流 对象值 注解和约束等 活动图基本 ...

  5. PAT 1005 Spell It Right

    1005 Spell It Right (20 分)   Given a non-negative integer N, your task is to compute the sum of all ...

  6. Spring注解之@validated的使用

    spring-boot中可以用@validated来校验数据,如果数据异常则会统一抛出异常,方便异常中心统一处理.比如,我们判断一个输入参数是否合法,可以用如下方式 一 基础使用 因为spring-b ...

  7. 解决SSH Secure Shell 连接Liunx 有乱码情况。

    输入:echo $LANG:查看当前使用系统语言 locale :安装是否是LANG="zh_CN.UTF-8":说明已经安装中文语言 步骤1:用root账户登录linux系统,或 ...

  8. 九校模拟——餐馆(restaurant)

    1 餐馆(restaurant) 1.1 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 1.2 题目描述 共有n 种食材,一份食材i 需要花ti 小时不间断地进行播种,施肥 ...

  9. ActiveMQ 配置jdbc主从

    使用 jdbc 方式配置主从模式,持久化消息存放在数据库中. 在同一时刻,只有一个 master broker,master 接受客户端的连接,slave 不接受连接.当 master 因为关机而下线 ...

  10. Vue中 computed 和 methods的区别

    涉及到计算部分的时候,计算属性是基于它们的依赖进行缓存的,如果说值不变,那么它就不会去重新执行,只有当值发生了改变,它才会去重新执行一次,其它时候它都是缓存的.而方法则会反复计算处理.二者之间的差距就 ...