Repository navigation
Fix Smartling localization breaking default fallback inheritance - #4907
murrayadam wants to merge 1 commit into
Conversation
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 95bea2c. Configure here.
| value: actualValue, | ||
| instructions, | ||
| }; | ||
| } |
There was a problem hiding this comment.
Metadata arrays still extracted for translation
Medium Severity
The new primitive-only extraction filter lives only in recordValue, which runs for Symbol inputs. getTranslateableFields still writes localized metadata arrays and objects such as productBenefits into the payload, so those fields continue to be sent to Smartling and the new test assertions do not hold.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 95bea2c. Configure here.
There was a problem hiding this comment.
Agreed. Extraction in getTranslateableFields now skips localized metadata whose value is an array, via a shared isTranslatableValue helper. The custom-component localized-input branch uses the same check.
| ...el, | ||
| [locale]: unescapeStringOrObject(translationValue), | ||
| }); | ||
| } |
There was a problem hiding this comment.
Object translations silently dropped on apply
High Severity
The new apply-side type guards reject every object-valued translation, so structured localized fields such as metadata.seo never receive locale overrides. Existing snapshots, the TranslateableFields type, and unescapeStringOrObject still treat objects as valid translation values.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 95bea2c. Configure here.
There was a problem hiding this comment.
Agreed. The guards now reject only arrays. Plain objects such as metadata.seo are still applied, matching TranslateableFields, unescapeStringOrObject and the existing snapshots.
There was a problem hiding this comment.
Builder reviewed your changes and found 2 potential issues 🔴
Review Details
Code Review Summary
This PR narrows translation extraction/application to primitive values to prevent Smartling from writing empty locale overrides for list/reference fields. The defense-in-depth approach is sensible, and the apply-side guards preserve existing localized defaults when provider responses contain arrays or objects. This is a standard-risk change because it modifies the shared translation data-processing path used by localization plugins.
Key findings
- 🔴 High: The added test is expected to fail: its localized metadata arrays are still unconditionally extracted by
getTranslateableFields; the new extraction guard only covers symbol data. This also leaves the reported metadata issue unresolved. - 🟡 Medium: The
resolveTranslationearly truthiness check rejects valid0andfalsevalues before the new guard can allow numeric/boolean translations. - The custom-component localized-input extraction branch also lacks a primitive type check, so non-text values may still be sent to translation although application ignores them.
The change is narrowly scoped, but extraction and application need consistent type filtering. 🧪 Browser testing: Will run after this review (PR touches UI code)
| expect(extractedFields['metadata.description'].value).toBe('Product description'); | ||
|
|
||
| // Should NOT extract array fields | ||
| expect(extractedFields['metadata.productBenefits']).toBeUndefined(); |
There was a problem hiding this comment.
🔴 test fails because localized metadata arrays are still extracted
getTranslateableFields still records every top-level localized metadata value without checking its type; the new guard only affects symbol data. With the array fixtures above, both metadata keys are populated, so these toBeUndefined() assertions fail and the arrays still reach Smartling. Add the primitive-value check to the metadata extraction branch.
There was a problem hiding this comment.
Agreed. Extraction now filters arrays for metadata, and the test passes. I also fixed the test's strict-null type errors.
| }); | ||
| // Only apply string, number, or boolean translations - not arrays or objects | ||
| // This prevents non-translatable fields (lists, references) from being applied | ||
| if (typeof translatedSymbolInput.value === 'string' || |
There was a problem hiding this comment.
🟡 Falsy primitive symbol translations are discarded before validation
The existing if (!translatedSymbolInput?.value) return check runs before this guard, so valid 0 or false values never reach the branch that explicitly permits numbers and booleans. Check for a missing value/property instead of truthiness so these supported primitive translations can be applied.
There was a problem hiding this comment.
Agreed. The early check now returns only for undefined, null or empty string, so 0 and false reach the type guard.
|
@builderio-bot Review all unresolved PR comments and the latest review feedback. For each comment:
After reviewing each comment:
Guidelines:
|
|
I agreed with all four review comments and fixed them in Fixed
Rejected: none. Needs a human decision: none. The Changeset bot also noted that the PR has no changeset. Add one if you want this released. |


Summary
Fixes an issue where localizing content with list/reference fields (e.g.,
productBenefits,FAQs,Localized Asset) through Smartling was creating unwanted locale-specific overrides with "Deleted entry" values, breaking default fallback inheritance.Problem
When translating Store Product entries containing localized list/reference fields:
This breaks the expected behavior where empty locales should inherit the Default locale values, preventing fallback inheritance.
Root Cause
The translation extraction logic was sending all localized field values to Smartling, including non-translatable data types:
Since Smartling is designed for text translation, it couldn't meaningfully translate these structures. When returned (as empty or with placeholders), the application logic applied them as locale-specific overrides, creating unwanted locale branches and breaking fallback.
Solution
Added type guards to filter non-translatable values during extraction and application:
Changes in
packages/utils/src/translation-helpers.ts1.
recordValue()function (line 60-70):2.
resolveTranslation()function (line 122-133):3.
applyTranslation()function (line 244-254 & 357-376):Test Coverage
Added comprehensive test case in
packages/utils/src/translation-helpers.test.ts:Testing
should not extract or apply non-string localized fields like arrays and referencesVerification
✅ Fixed
✅ No Regressions
Breaking Changes
None. This fix only prevents non-translatable data types from being processed. All existing text-based translation functionality remains unchanged.
Files Changed
packages/utils/src/translation-helpers.ts- Core fix with type guardspackages/utils/src/translation-helpers.test.ts- New test caseNote
Medium Risk
Changes how localized content is merged after translation jobs; incorrect guards could drop valid translations or leave bad data unfiltered, but scope is limited to type checks on apply/extract paths with new test coverage.
Overview
Fixes Smartling round-trips writing empty or invalid locale overrides on localized list/reference fields, which broke Default fallback and showed “Deleted entry” in the editor.
Translation helpers now only treat string, number, and boolean values as translatable when extracting nested localized symbol data (
recordValue) and when applying translations for metadata, symbol inputs (resolveTranslation), and custom component localized inputs. Arrays and objects are skipped on apply even if the translation payload includes them (e.g. empty arrays from Smartling).Adds a unit test confirming scalar fields still extract/apply while localized array fields like
productBenefitsdo not get a target-locale branch.Reviewed by Cursor Bugbot for commit 95bea2c. Bugbot is set up for automated code reviews on this repo. Configure here.