Skip to content

Add script to check and correct SPO Site Pages translation config#963

Open
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:check-and-correct-translation-config
Open

Add script to check and correct SPO Site Pages translation config#963
fabianhutzli wants to merge 1 commit into
pnp:mainfrom
fabianhutzli:check-and-correct-translation-config

Conversation

@fabianhutzli

Copy link
Copy Markdown
Contributor

Summary

This sample validates the SharePoint multilingual translation metadata for every page in the Site Pages library and optionally corrects clear-cut misconfigurations. It is useful when translation fields get out of sync — for example after manual page moves, bulk imports, or failed translation setups — and there is no easy way to identify the affected pages at scale.

The script classifies each page into one of three roles and checks the expected field state for each:

Role Condition Expected state
Standalone Only one page with this filename, not a translation All _SP* fields empty
Master page Multiple pages share the same filename, _SPIsTranslation is false _SPTranslatedLanguages lists exactly all translation languages; other fields empty
Translated page _SPIsTranslation is true _SPTranslationLanguage and _SPTranslationSourceItemId set; _SPTranslatedLanguages empty

Features

  • Report mode (default): lists all issues as a table with file name, page type, issue description, UniqueId, and list item ID
  • Fix mode (-Fix switch): automatically corrects unambiguous cases:
    • Clears stale translation fields on standalone and master pages
    • Derives a missing _SPTranslationLanguage on a translated page by subtracting languages claimed by sibling translations from the master's _SPTranslatedLanguages list — fixable when exactly one language remains
    • Resolves a missing _SPTranslationSourceItemId by finding the sole non-translation page that shares the same filename — fixable when exactly one candidate exists
  • Issues that cannot be resolved unambiguously are flagged for manual review

Script type

PnP PowerShell

Author

Fabian Hutzli

Validates _SPTranslatedLanguages, _SPTranslationLanguage, _SPTranslationSourceItemId
and _SPIsTranslation for every page in the Site Pages library across three roles
(standalone, master, translated). Optionally corrects clear-cut misconfigurations
via -Fix, including deriving a missing _SPTranslationLanguage from the master's
language list and resolving a missing _SPTranslationSourceItemId from sibling pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant