It has been a while since I wrote an article about SharePoint, but in the last couple of weeks, I got interested in linking and unlinking multilingual pages in SharePoint. This functionality is proper when you migrate pages from other sites to multilingual ones. Still, it can also be helpful to remap pages in case of some information architecture changes. Out-of-the-box SharePoint does not provide this functionality, but you can achieve it using the SharePoint REST API.
info Read the following article to get more background information on how multilingual pages work in SharePoint - Using the new multilingual APIs in Modern SharePoint
In this article, I will show you how to link and unlink multilingual pages in SharePoint using the SharePoint REST API.
Before you can start linking and unlinking multilingual pages, you will need to get the following things:
- The form digest value of the site, we need to perform an update on the list items endpoint
- Disable read-only on the following fields
_SPTranslationSourceItemIdof the Site Pages library
Getting the form digest value
You can retrieve the form digest value via the
/_api/contextinfo API or use the
DigestCache service in SPFx.
Disabling read-only on the fields
To link and unlink a page, you need to set/unset values in the
_SPTranslationSourceItemId fields. By default, they are set to read-only, so before an update, you will need to turn off the read-only flag and enable it after the update.
ReadOnlyFieldproperty is where you define if the field is read-only or not.
Linking multilingual pages
In case you want to link a specific page to a multilingual page, you will need to get the following things:
- The source ID (better known as the
UniqueId) of the page in the default language
- The locale of the page
- The ID (list item ID) of the page to link
For example, the default language of my site is English (en-us), and I want to link a Dutch (nl-nl) page to the English source page. I need the
UniqueId of the English page, the Dutch page’s list item ID, and the locale.
UniqueIdof the English page:
<locale>: Locale of the Dutch page:
<item id>: The list ID of the Dutch page:
You can link the Dutch page to the English page with these three things. You can do this with the following REST API call:
info We set the
_SPIsTranslationto let SharePoint know it is a translation linked to the source page.
Once you have executed this call, you will see that the Dutch page is linked to the English page.
Unlinking multilingual pages
Unlinking a multilingual page is similar to linking a page. You can use the action to remove the link between the source page and the translation page to allow another page to be linked to the source page.
The call to perform is similar to the page linking one, but now we need to unset the
_SPTranslationSourceItemId field value.
Once you have performed the (un)link calls, do not forget to set the read-only flag back to
true on the fields.