Skip to content

Resolve "Script to apply Source Entry Reference Fields on Software Faster"

Step 1: What is changing in this MR?

  • Added script to prepare a page for argo translations by doing the following steps:
    • Checks each content type in the page to make sure it supports the Source Entry field, if it doesn't it updates the content model to add this field
    • Relates each localized entry with its english counterpart through the Source Entry field
    • Adds the relevant locale tag in contentful to the updated entry
    • Updates the content in contentful without publishing it (it remains in Changed state)
    • It will then navigate the components and see witch of those are references, the look at the source components and match the references across. this is a recursive process and it will keep going deeper in the tree until it no longer finds reference fields.
    • It will then check for entries that were tagged multiple times since this means the same entry is being referenced in different locale entries, for any entries identified will multiple tags the script will remove the tags and clear the Source Entry field

Assumptions

Since there is not direct relationship between the localized entries and their source entry before running the script it has to rely on some assumptions beforehand

  1. The Source Entry is always the english version of the entry
  2. The page has the same components and in the same order in all locales. this is because components are linked based on their position in the component array
  3. The page to be updated uses the PAGE content type

Running the script

To run the script use the commad:

node scripts/entryLevelLocalization.js CMA_ACCESS_TOKEN SPACE_ID PAGE_ID

The script is added in this MR to the codebase, after we finish with the entry level updates it will be moved away from the codebase and into the snippets section of the repository

Test results:

This script was tested on two pages:

Closes #3727

Closes gitlab-com/localization/localization-team#82 (closed)

Edited by Mateo Penagos

Merge request reports