Skip to content

fix[utils][smartling]: ENG-12274 smartling plugin skips nested fields for translation#4651

Open
AishwaryaParab wants to merge 2 commits into
mainfrom
ENG-12274_smartling_skips_nested_fields
Open

fix[utils][smartling]: ENG-12274 smartling plugin skips nested fields for translation#4651
AishwaryaParab wants to merge 2 commits into
mainfrom
ENG-12274_smartling_skips_nested_fields

Conversation

@AishwaryaParab

@AishwaryaParab AishwaryaParab commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

When a data model field has the Localize toggle enabled, Builder stores the entire array as a single LocalizedValue object. The Smartling plugin was not sending the individual string fields inside that array for translation. So, only the parent field was recorded, but as a non-string value that Smartling cannot translate.

Example data structure that was broken:

"items": {
  "@type": "@builder.io/core:LocalizedValue",
  "Default": [
    { "question": "What does an Excel expert do?", "answer": "An Excel expert..." }
  ]
}

question and answer were dropped and nothing reached Smartling.

Fix:
Updated getTranslateableFields in @builder.io/utils to recursively walk into array/object payloads of a LocalizedValue and extract individual string leaves as separate translation entries:

  • metadata.faqs#items#0#question → "What does an Excel expert do?"
  • metadata.faqs#items#0#answer → "An Excel expert..."

Also updated applyTranslation to correctly write translated values back into the right position in the locale-specific copy of the array.

Two new unit tests added:

  • Verifies extraction produces the correct flat string keys for nested array fields
  • Verifies apply-back correctly populates the target locale slot while preserving Default

Screenshot
https://www.loom.com/share/e0e1bad23bac408d8ee17619a60bac07


Note

Medium Risk
Changes how localized custom-field content is read and written during translation; mistakes could corrupt locale data, though behavior is covered by new tests and sourceLocaleId is optional.

Overview
Fixes Smartling/metadata translation when a Localized custom field stores an array or object (e.g. FAQ items) instead of a single string. Previously only the parent field was exported—often as a non-translatable blob—so nested strings never reached Smartling.

getTranslateableFields now walks content metadata with a custom recursive extractor that stops at LocalizedValue boundaries and uses extractNestedStrings to emit one translatable entry per string leaf (e.g. metadata.faqs#items#0#question). Nested object fields under localized SEO now appear as separate keys in snapshots instead of one whole-object entry.

applyTranslation gains an optional sourceLocaleId, matches compound translation keys under each LocalizedValue, deep-clones the source locale payload (preferring sourceLocaleId over Default), patches leaves (keeping nested LocalizedValue objects intact), and stores the result on the target locale.

New unit tests cover FAQ extraction/apply-back, double-localized sub-fields, and source-locale structure when it diverges from Default.

Reviewed by Cursor Bugbot for commit d68fc77. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d68fc77

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud

nx-cloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit d68fc77

Command Status Duration Result
nx test @e2e/qwik-city ✅ Succeeded 7m 43s View ↗
nx test @e2e/nextjs-sdk-next-app ✅ Succeeded 6m 53s View ↗
nx test @e2e/angular-17 ✅ Succeeded 6m 12s View ↗
nx test @e2e/angular-17-ssr ✅ Succeeded 5m 27s View ↗
nx test @e2e/hydrogen ✅ Succeeded 5m 22s View ↗
nx test @e2e/nuxt ✅ Succeeded 5m 32s View ↗
nx test @e2e/gen1-next15-app ✅ Succeeded 4m 47s View ↗
nx test @e2e/angular-19-ssr ✅ Succeeded 5m 16s View ↗
Additional runs (38) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-09 12:20:57 UTC

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3fe5e6d. Configure here.

Comment thread packages/utils/src/translation-helpers.ts
Comment thread packages/utils/src/translation-helpers.ts Outdated
@AishwaryaParab AishwaryaParab requested review from a team, anaghav2023 and floating-dynamo and removed request for a team June 9, 2026 12:38

@anaghav2023 anaghav2023 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AishwaryaParab changes look good. I think this is tested on a data model content entry. Better to test this on a normal page model content entry as well

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.

2 participants