SOLVED

How to provision web part titles in multiple languages using Office Dev PnP Provisioning?

%3CLINGO-SUB%20id%3D%22lingo-sub-7353%22%20slang%3D%22en-US%22%3EHow%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-7353%22%20slang%3D%22en-US%22%3E%3CP%3EUsing%20the%20Office%20Dev%20PnP%26nbsp%3Bprovisioning%20engine%20I've%20managed%20to%20deploy%20a%20site%20in%20multiple%20languages.%20We%20managed%20to%20localize%20just%20a%20few%20of%20the%20web%20part%20titles%20shown%20on%20the%20welcome%20page%20of%20our%20site%3A%3C%2FP%3E%3CUL%3E%3CLI%3EThe%20web%20part%20titles%20of%20our%20announcements%2C%20tasks%20and%20documents%20lists%2Flibraries%20are%20localized.%3C%2FLI%3E%3CLI%3EThe%20web%20part%20titles%20of%20a%20calendar%2C%20the%20contact%20details%20and%20site%20users%20web%20part%20are%20not%20shown%20in%20a%20localized%20language%20yet.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EBelow%20you'll%20see%20how%20we%20define%20the%20web%20parts%20and%20would%20expect%20these%20to%20be%20localized%2C%20a%20few%20support%20it%2C%20others%20simply%20fall%20back%20to%20English.%3C%2FP%3E%3CP%3EHow%20can%20we%20realize%20localization%20for%20all%20the%20web%20part%20titles%3F%3C%2FP%3E%3CP%3EOr%20is%20localization%20only%20supported%20for%20v3%20Web%20Parts%20(which%20I%20expect%20based%20on%20our%20test%20results)%3F%20If%20so%2C%20is%20it%20possible%20to%20%22convert%22%20the%20v2%20web%20part%20definition%20to%20a%20v3%20definition%3F%20Do%20you%20have%20an%20example%20for%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWorking%20for%20the%20documents%20library%20(displays%20in%20English%20or%20Dutch%20language%20based%20on%20the%20user)%3C%2FP%3E%3CPRE%3E%26lt%3Bpnp%3AWebPart%20Title%3D%22Documents%22%20Row%3D%221%22%20Column%3D%221%22%26gt%3B%0A%26lt%3Bpnp%3AContents%26gt%3B%0A%26lt%3BwebParts%26gt%3B%0A%26lt%3BwebPart%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FWebPart%2Fv3%22%26gt%3B%0A%26lt%3BmetaData%26gt%3B%0A%26lt%3Btype%20name%3D%22Microsoft.SharePoint.WebPartPages.XsltListViewWebPart%2C%20Microsoft.SharePoint%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c%22%20%2F%26gt%3B%0A%26lt%3BimportErrorMessage%26gt%3BCannot%20import%20the%20Documents%20Web%20Part.%26lt%3B%2FimportErrorMessage%26gt%3B%0A%26lt%3B%2FmetaData%26gt%3B%0A%26lt%3Bdata%26gt%3B%0A%26lt%3Bproperties%26gt%3B%0A%26lt%3Bproperty%20name%3D%22ShowWithSampleData%22%20type%3D%22bool%22%26gt%3BFalse%26lt%3B%2Fproperty%26gt%3B%0A%26lt%3Bproperty%20name%3D%22ListName%22%20type%3D%22string%22%26gt%3B%7B%7Blistid%3ADocuments%7D%7D%26lt%3B%2Fproperty%26gt%3B%0A%26lt%3Bproperty%20name%3D%22Title%22%20type%3D%22string%22%20%2F%26gt%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20working%20for%20the%20Site%20Users%20web%20part%20(always%20displays%20the%20English%20language)%3C%2FP%3E%3CPRE%3E%26lt%3Bpnp%3AWebPart%20Title%3D%22Site%20Users%22%20Row%3D%221%22%20Column%3D%222%22%26gt%3B%0A%26lt%3Bpnp%3AContents%26gt%3B%0A%26lt%3BWebPart%20xmlns%3Axsd%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FWebPart%2Fv2%22%26gt%3B%0A%26lt%3BTitle%26gt%3B%7Bresource%3ASiteUsersWebPartTitle%7D%26lt%3B%2FTitle%26gt%3B%0A%26lt%3BAssembly%26gt%3BMicrosoft.SharePoint%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c%26lt%3B%2FAssembly%26gt%3B%0A%26lt%3BTypeName%26gt%3BMicrosoft.SharePoint.WebPartPages.MembersWebPart%26lt%3B%2FTypeName%26gt%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20900px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F2434i7B65F2E99C5AAA65%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Site%20Users%20web%20part%20showing%20web%20part%20title%20in%20incorrect%20language.png%22%20title%3D%22Site%20Users%20web%20part%20showing%20web%20part%20title%20in%20incorrect%20language.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20working%20for%20the%20Contact%20Details%20(always%20displays%20the%20English%20language)%3C%2FP%3E%3CPRE%3E%3CWEBPART%20title%3D%22Contact%20Details%22%20row%3D%221%22%20column%3D%222%22%3E%3CCONTENTS%3E%3CWEBPART%20xsd%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FWebPart%2Fv2%22%3E%3CBR%20%2F%3E%3CTITLE%3E%7Bresource%3AContactDetailsWebPartTitle%7D%3C%2FTITLE%3E%3CBR%20%2F%3E%3CASSEMBLY%3EMicrosoft.SharePoint.Portal%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c%3C%2FASSEMBLY%3E%3CBR%20%2F%3E%26lt%3BTypeName%26gt%3BMicrosoft.SharePoint.Portal.WebControls.ContactFieldControl%26lt%3B%2FTypeName%26gt%3B%3C%2FWEBPART%3E%3C%2FCONTENTS%3E%3C%2FWEBPART%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20working%20for%20the%20Calendar%20web%20part%20(always%20displays%20the%20English%20language)%3C%2FP%3E%3CPRE%3E%3CWEBPART%20title%3D%22Calendar%22%20row%3D%221%22%20column%3D%222%22%3E%3CBR%20%2F%3E%3CCONTENTS%3E%3CBR%20%2F%3E%3CWEBPART%20xsd%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%22%20xsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%20xmlns%3D%22http%3A%2F%2Fschemas.microsoft.com%2FWebPart%2Fv2%22%3E%3CBR%20%2F%3E%3CTITLE%3E%7Bresource%3ACalendarListTitle%7D%3C%2FTITLE%3E%3CBR%20%2F%3E%3CASSEMBLY%3EMicrosoft.SharePoint%2C%20Version%3D16.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D71e9bce111e9429c%3C%2FASSEMBLY%3E%3CBR%20%2F%3E%26lt%3BTypeName%26gt%3BMicrosoft.SharePoint.WebPartPages.ListViewWebPart%26lt%3B%2FTypeName%26gt%3B%3C%2FWEBPART%3E%3C%2FCONTENTS%3E%3C%2FWEBPART%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71907%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71907%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20some%20new%20information%20on%20this%20topic.%3C%2FP%3E%3CP%3EFor%20me%20(SP2016%20on%20Prem)%26nbsp%3Bthe%20webparts%20do%20change%20their%20webpart-title%20based%20on%20the%20users%20language%2C%20if%20the%20additional%20language%20is%20activated%20in%20the%20site%20settings.%3C%2FP%3E%3CP%3EI%20also%20found%20out%2C%20why%20some%20webparts%20had%20a%20correct%20tranlation%20and%20other%20didn't%3A%3C%2FP%3E%3CP%3EThe%20PnP%20Code%20for%20the%20translation%20goes%20thorugh%20all%20open%20webparts%20on%20the%20page.%20To%20find%20out%20if%20a%20webpart%20is%20open%2C%20a%20comparison%20is%20made%20between%20the%20webpart-order%20in%20XML%20and%20%22in%20reality%22%20(this%20must%20be%20the%20XML%20retrieved%20by%20some%20get-webpart-from-page%20method).%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fblob%2Fmaster%2FCore%2FOfficeDevPnP.Core%2FFramework%2FProvisioning%2FObjectHandlers%2FExtensions%2FLocalizationExtensions.cs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fblob%2Fmaster%2FCore%2FOfficeDevPnP.Core%2FFramework%2FProvisioning%2FObjectHandlers%2FExtensions%2FLocalizationExtensions.cs%3C%2FA%3E%3C%2FP%3E%3CTABLE%3E%3CTBODY%3E%3CTR%3E%3CTD%3E%23if%20%3CSPAN%20class%3D%22pl-en%22%3E%3CFONT%20face%3D%22Consolas%22%3E!SP2016%3C%2FFONT%3E%3C%2FSPAN%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%3CSPAN%20class%3D%22pl-k%22%3E%3CFONT%20face%3D%22Consolas%22%3Evar%3C%2FFONT%3E%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3E%3CFONT%20face%3D%22Consolas%22%3EpartOnPage%20%3C%2FFONT%3E%3C%2FSPAN%3E%3D%20allParts.FirstOrDefault(w%20%3D%26gt%3B%20w.ZoneId%20%3D%3D%20webPart.Zone%20%26amp%3B%26amp%3B%20w.WebPart.ZoneIndex%20%3D%3D%20webPart.Order)%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%23else%26nbsp%3B%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3CTD%3E%3CSPAN%20class%3D%22pl-k%22%3E%3CFONT%20face%3D%22Consolas%22%3Evar%3C%2FFONT%3E%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22pl-en%22%3E%3CFONT%20face%3D%22Consolas%22%3EpartOnPage%20%3C%2FFONT%3E%3C%2FSPAN%3E%3D%20allParts.FirstOrDefault(w%20%3D%26gt%3B%20w.WebPart.ZoneIndex%20%3D%3D%20webPart.Order)%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E%26nbsp%3B%23endif%3C%2FTD%3E%3CTD%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20use%20a%20wikipage%20the%20order%20will%20always%20be%20%220%22%20-%20so%20the%20translation%20is%20overwritten%20several%20times.%20Thats%20why%20it%20didn't%20work%20in%20my%20case.%3C%2FP%3E%3CP%3EWith%20webpart%20pages%20there%20is%20another%20problem%20with%20SP2016%3A%20As%20only%20the%20ZoneIndex%20is%20compared%20and%20not%20the%20webpartZone%20your%20webpart-order%20has%20to%20be%20unique%20across%20all%20zones.%20This%20is%20impossible%20for%20two%20or%20more%20zones%2C%20as%20the%20first%20webpart%20added%20to%20an%20empty%20zone%20always%20gets%20a%20%220%22%20as%20order.%20As%20a%20result%20the%20two%20webparts%20on%20top%20of%20the%20webpart%20zone%20will%20have%20wrong%20translations.%3C%2FP%3E%3CP%3EI'll%20make%20a%20bug%20at%20github%20in%20the%20next%20days%20to%20see%20if%20there%20is%20a%20reason%20for%20this%20SP2016-Exception.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71554%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71554%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20reactions.%20I%20wasn't%20able%20to%20find%20the%20solution%20in%20the%20past.%20Your%26nbsp%3Bcontributions%20are%20helpful%2C%20I%20will%20try%20it%20out%20sometime%20when%20I%20need%20it%20for%20a%20new%20multilingual%26nbsp%3Bproject.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69459%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69459%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Harold%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20did%20a%20big%20multi%20langual%20project%20and%20managed%20to%20get%20it%20working%20for%20all%20my%20webparts.%20In%20my%20experience%20your%20need%20to%20put%20the%20language%20tokens%20in%20bot%20the%20pnp%3Awebpart%20title%20attribute%20as%20in%20the%20webpart%20xml%20title%20property.%20Both%20needs%20to%20be%20the%20same.%20All%20localization%20files%20needs%20to%20be%20refered%20to%20in%20your%20template%20and%20als%20the%20supported%20languages%20needs%20to%20be%20set.%20This%20way%20it%20works%20in%20my%20opinion.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20thing%20to%20note%20here%3A%20The%20webparts%20only%20show%20in%20the%20language%20of%20the%20site%20and%20does%20not%20follow%20the%20users%20language.%20So%20if%20a%20German%20user%20visits%20a%20French%20site%2C%20the%20webpart%20titles%20are%20shown%20in%20German.%20Not%20in%20French.%20I%20would%20have%20expected%20that%20the%20users%20language%20would%20be%20leading%20here%2C%20but%20haven't%20seen%20it%20work%20like%20that.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69456%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69456%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20figured%20out%20the%20behavior%20in%20my%20case%3A%20It%20is%20not%20related%20to%20the%20type%20of%20webpart%20but%20to%20the%20order%20the%20webparts%20are%20provisioned.%20Only%20the%20last%20Webpart%20in%20my%20PnP-Template-XML%20will%20get%20a%20translated%20title.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMore%20testing%20is%20in%20progress.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-69173%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20provision%20web%20part%20titles%20in%20multiple%20languages%20using%20Office%20Dev%20PnP%20Provisioning%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69173%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Harold%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20currently%20a%20very%20similar%20problem%3A%20Some%20webpart%20titles%20%22accept%22%20the%20ressource-string%20others%20just%20always%20display%20their%20english%20title.%3C%2FP%3E%3CP%3EI'm%20using%20SharePpoint%202016%20with%20PnP%20Partner%20Pack%20to%20provision%20the%20webparts.%3C%2FP%3E%3CP%3EFor%20me%20the%20CSWP%20is%20translated%20correctly.%3C%2FP%3E%3CP%3ENot%20translated%3A%20Script-Editor-Webpart%20and%20Project%20Summary%20Webpart.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDid%20you%20ever%20find%20out%20what%20the%20problem%20was%3F%20Currently%20I%20guess%20that%20some%20webparts%20render%20server-side%20and%20some%20render%20client-side.%20Depending%20on%20the%20render%20mode%20it%20fails%20or%20it%20works%20-%20but%20till%20now%20I%20couldn't%20test%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Frequent Contributor

Using the Office Dev PnP provisioning engine I've managed to deploy a site in multiple languages. We managed to localize just a few of the web part titles shown on the welcome page of our site:

  • The web part titles of our announcements, tasks and documents lists/libraries are localized.
  • The web part titles of a calendar, the contact details and site users web part are not shown in a localized language yet.

Below you'll see how we define the web parts and would expect these to be localized, a few support it, others simply fall back to English.

How can we realize localization for all the web part titles?

Or is localization only supported for v3 Web Parts (which I expect based on our test results)? If so, is it possible to "convert" the v2 web part definition to a v3 definition? Do you have an example for that?

 

Working for the documents library (displays in English or Dutch language based on the user)

<pnp:WebPart Title="Documents" Row="1" Column="1">
<pnp:Contents>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import the Documents Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="ListName" type="string">{{listid:Documents}}</property>
<property name="Title" type="string" />

 

 

Not working for the Site Users web part (always displays the English language)

<pnp:WebPart Title="Site Users" Row="1" Column="2">
<pnp:Contents>
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>{resource:SiteUsersWebPartTitle}</Title>
<Assembly>Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.MembersWebPart</TypeName>

 Site Users web part showing web part title in incorrect language.png

 

Not working for the Contact Details (always displays the English language)

<pnp:WebPart Title="Contact Details" Row="1" Column="2"><pnp:Contents><WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>{resource:ContactDetailsWebPartTitle}</Title>
<Assembly>Microsoft.SharePoint.Portal, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.Portal.WebControls.ContactFieldControl</TypeName>

 

 

Not working for the Calendar web part (always displays the English language)

<pnp:WebPart Title="Calendar" Row="1" Column="2">
<pnp:Contents>
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
<Title>{resource:CalendarListTitle}</Title>
<Assembly>Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>

 

5 Replies
Highlighted

Hi Harold,

 

I have currently a very similar problem: Some webpart titles "accept" the ressource-string others just always display their english title.

I'm using SharePpoint 2016 with PnP Partner Pack to provision the webparts.

For me the CSWP is translated correctly.

Not translated: Script-Editor-Webpart and Project Summary Webpart.

 

Did you ever find out what the problem was? Currently I guess that some webparts render server-side and some render client-side. Depending on the render mode it fails or it works - but till now I couldn't test it.

Highlighted

Hi,

 

I just figured out the behavior in my case: It is not related to the type of webpart but to the order the webparts are provisioned. Only the last Webpart in my PnP-Template-XML will get a translated title.

 

More testing is in progress.

Highlighted
Solution

Hi Harold,

 

I did a big multi langual project and managed to get it working for all my webparts. In my experience your need to put the language tokens in bot the pnp:webpart title attribute as in the webpart xml title property. Both needs to be the same. All localization files needs to be refered to in your template and als the supported languages needs to be set. This way it works in my opinion.

 

One thing to note here: The webparts only show in the language of the site and does not follow the users language. So if a German user visits a French site, the webpart titles are shown in German. Not in French. I would have expected that the users language would be leading here, but haven't seen it work like that.

Highlighted

Thanks for the reactions. I wasn't able to find the solution in the past. Your contributions are helpful, I will try it out sometime when I need it for a new multilingual project.

Highlighted

Hi,

 

I have some new information on this topic.

For me (SP2016 on Prem) the webparts do change their webpart-title based on the users language, if the additional language is activated in the site settings.

I also found out, why some webparts had a correct tranlation and other didn't:

The PnP Code for the translation goes thorugh all open webparts on the page. To find out if a webpart is open, a comparison is made between the webpart-order in XML and "in reality" (this must be the XML retrieved by some get-webpart-from-page method).

https://github.com/SharePoint/PnP-Sites-Core/blob/master/Core/OfficeDevPnP.Core/Framework/Provisioni...

#if !SP2016
 var partOnPage = allParts.FirstOrDefault(w => w.ZoneId == webPart.Zone && w.WebPart.ZoneIndex == webPart.Order);
#else  
 var partOnPage = allParts.FirstOrDefault(w => w.WebPart.ZoneIndex == webPart.Order);
 #endif 

 

If you use a wikipage the order will always be "0" - so the translation is overwritten several times. Thats why it didn't work in my case.

With webpart pages there is another problem with SP2016: As only the ZoneIndex is compared and not the webpartZone your webpart-order has to be unique across all zones. This is impossible for two or more zones, as the first webpart added to an empty zone always gets a "0" as order. As a result the two webparts on top of the webpart zone will have wrong translations.

I'll make a bug at github in the next days to see if there is a reason for this SP2016-Exception.