博客地址: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. LeetCode--004--寻找两个有序数组的中位数(java)

    转自https://blog.csdn.net/chen_xinjia/article/details/69258706 其中,N1=4,N2=6,size=4+6=10. 1,现在有的是两个已经排好 ...

  2. Nginx安装与使用 及在redhat 中的简单安装方式

    首先说下在redhat中的安装方法, 正常安装nginx 需要安装很多的依赖,最后再安装nginx,而且很容易出错. 在nginx官方上有这么一段描述: Pre-Built Packages for ...

  3. Gifts by the List CodeForces - 681D (思维)

    大意: 给定森林, 要求构造一个表, 满足对于每个$x$, 表中第一次出现的$x$的祖先(包括$x$)是$a_x$. 刚开始还想着直接暴力分块优化一下连边, 最后按拓扑序输出... 实际上可以发现$a ...

  4. 【Java】【3】BeanUtils.copyProperties();将一个实体类的值复制到另外一个实体类

    正文: a,b为对象 BeanUtils.copyProperties(a,  b); 1,BeanUtils是org.springframework.beans.BeanUtils, a拷贝到b 2 ...

  5. 子类父类(虚函数下的 引用指针 对象)->看来没有子类指针这回事

    #include<iostream> using namespace std; class Father { public: Father() { cout << " ...

  6. navicat 连接 mysql 解决出现client does not support authentication protocol requested by server的问题

    MySQL8换了加密插件,数据库管理客户端都来不及更新,连接方式缺乏sha2的加密方式首先第一步, UPDATE mysql.user SET plugin = 'mysql_native_passw ...

  7. 使用SpringBoot集成ActiveMQ

    SpringBoot是个好东西,好多java常用的东西都被集成进去了 JMS 在 Spring Boot 中的使用 使用Spring/Spring Boot集成JMS的陷阱 Spring-boot J ...

  8. python爬虫---BeautifulSoup的用法

    BeautifulSoup是一个灵活的网页解析库,不需要编写正则表达式即可提取有效信息. 推荐使用lxml作为解析器,因为效率更高. 在Python2.7.3之前的版本和Python3中3.2.2之前 ...

  9. 2015-09-16 html课程总结1

    HTML (HyperText Makeup Language)是超文本标记语言. 1.HTML结构 <html> <head> <title>标题</tit ...

  10. 【转】JavaScript => TypeScript 入门

    几个月前把 ES6 的特性都过了一遍,收获颇丰.现在继续来看看 TypesScript(下文简称为 “TS”).限于经验,本文一些总结如有不当,欢迎指正. 官网有这样一段描述: TypeScript ...