Forum Discussion
HaroldvandeKamp
Aug 25, 2016Bronze Contributor
How to provision web part titles in multiple languages using Office Dev PnP Provisioning?
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...
- May 12, 2017
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.
May 12, 2017
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.
- HaroldvandeKampMay 19, 2017Bronze Contributor
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.
- Markus IhloffMay 22, 2017Copper Contributor
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).
#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.