SharePoint Pals
 | Sign In
How to Provision Multi Lingual Site Columns and Content Types using Provisioning Template by Patterns and Practices PNP in SharePoint Office 365
by Sathish Nadarajan 19 Jul 2016
Author
SharePoint MVP
Visits   
Today  :   19     Total  :    4244

In the earlier article, we saw the Provisioning Template and its usage. Now, again, let us see how to use the provisioning Template for various language Sites.

To explain the problem statement in detail, I have created a French Publishing Site Collection.

clip_image002

If we have a close look at the Site, even the Site Column and the Content Type, Content, almost everything in the Site will be in French only.

clip_image004

When I execute the Below Method, (Which is best described here), the Site Columns got created in English. Not in French.

 private static void ProvisioningDemo()
         {
             OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
             string siteURL = "https://sppals.sharepoint.com/sites/FrenchPublishingSite";
             string userName = "sathish@sppals.onmicrosoft.com";
             string password = "*******";
             string file = "ProvisioningTemplate.xml";
 
             string directory = "D:\\PRACTICE SOURCE CODE\\PNP\\Provisioning.Console\\Provisioning.Console\\Template";
             var provisioningProvider = new XMLFileSystemTemplateProvider(directory, string.Empty);
             var provisioningTemplate = provisioningProvider.GetTemplate(file);
             provisioningTemplate.Connector.Parameters[FileConnectorBase.CONNECTIONSTRING] = directory;
 
             using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteURL, userName, password))
             {
                 ctx.Load(ctx.Web);
                 ctx.ExecuteQueryRetry();
                 ctx.Web.ApplyProvisioningTemplate(provisioningTemplate);
                 ctx.ExecuteQueryRetry();
             }
 
             System.Console.ReadLine();
         }
 

clip_image006

Now, the requirement is like, even the Site Columns should also get created in Various Languages. i.e., If the Site Language is French, then the Site Columns should get created in French. If it is German, then the Site Columns should also get created in German. Basically, the Provisioning Should work based on the Language of the Site.

For that, let us have a step by step procedure.

1. Open the Console Application.

2. Add the Resource File for French in the Templates Folder.

clip_image008

3. Name the Resource File as SiteColumns-fr-FR.resx.

4. Add the below values to the Resource File.

clip_image010

5. Update the ProvisioningTemplate.xml as below.

 <?xml version="1.0"?>
 <pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema">
   <pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.0.1601.0, Culture=neutral, PublicKeyToken=null" />
   <pnp:Localizations>
     <pnp:Localization LCID="1036" Name="French" ResourceFile="SiteColumns-fr-FR.resx"/>
   </pnp:Localizations>
   <pnp:Templates ID="CONTAINER-SharePointPalsDemo">
     <pnp:ProvisioningTemplate ID="SharePointPalsDemo" Version="1" xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema">
 
 
 
       <pnp:SiteFields>
 
 
         <Field ID="{793F0419-9A72-48D9-B983-91BD359E5387}" Name="{resource:MyCustomPNPFieldInternalName}" StaticName="MyCustomPNPField" DisplayName="{resource:MyCustomPNPFieldDisplayName}" Type="Note" Required="FALSE" RichText="FALSE" Group="My Custom PNP Fields" />
 
       </pnp:SiteFields>
 
       <pnp:ContentTypes>
 
         <!-- Bookmark ContentTypes -->
         <pnp:ContentType ID="0x010500C562BA980E1C457B97298CA27EC2C843" Name="MyCustomContentType" Description="Test Description" Group="Custom Group">
           <pnp:FieldRefs>
             <pnp:FieldRef ID="793F0419-9A72-48D9-B983-91BD359E5387" Name="{resource:MyCustomPNPFieldInternalName}" />
           </pnp:FieldRefs>
         </pnp:ContentType>
 
       </pnp:ContentTypes>
 
     </pnp:ProvisioningTemplate>
   </pnp:Templates>
 </pnp:Provisioning>
 

6. Now, execute the Program.

7. Go back to the Site Columns in the Site Settings.

8. We will be seeing the SiteColumns got created in French.

9. There is no change on the CSharp. Only the XML changed from the earlier article. The PNP decides which resource file should be picked up based on the LCID

clip_image012

Download the Source HERE

Happy Coding,

Sathish Nadarajan.

blog comments powered by Disqus

SharePoint Pals

Pals
SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile

Training

Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community




SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to articles@sharepointpals.com in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart https://t.co/VxSi4QnNrC

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window https://t.co/EQ7HkoZDkX

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features https://t.co/zAXObHCFpH

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013 https://t.co/LEwnUoI7EY

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services https://t.co/Yvp2VPFIRP

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation