diff --git a/packages/utils/package-lock.json b/packages/utils/package-lock.json index 439c7f3d6ae..9aedf1cffaa 100644 --- a/packages/utils/package-lock.json +++ b/packages/utils/package-lock.json @@ -1,12 +1,12 @@ { "name": "@builder.io/utils", - "version": "1.1.29", + "version": "1.1.27", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@builder.io/utils", - "version": "1.1.29", + "version": "1.1.27", "dependencies": { "@types/lodash": "^4.14.182", "lodash": "^4.17.21", diff --git a/packages/utils/package.json b/packages/utils/package.json index ed5000092cd..7bf69486e92 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@builder.io/utils", - "version": "1.1.29", + "version": "1.1.27", "description": "Utils for working with Builder.io content", "main": "./dist/index.js", "scripts": { diff --git a/packages/utils/src/__snapshots__/translation-helpers.test.ts.snap b/packages/utils/src/__snapshots__/translation-helpers.test.ts.snap index 9cce4fe1ddd..2eabfa0e0c8 100644 --- a/packages/utils/src/__snapshots__/translation-helpers.test.ts.snap +++ b/packages/utils/src/__snapshots__/translation-helpers.test.ts.snap @@ -322,31 +322,6 @@ Object { } `; -exports[`getTranslateableFields from carousel content and custom component with subFields to match snapshot 1`] = ` -Object { - "blocks.builder-06d3f6da74fb4054ad311afc1dda3675#text": Object { - "instructions": "Visit https://builder.io/fiddle/... for more details", - "value": "

I am slide second

", - }, - "blocks.builder-0a10ae48b6314221bbb7d06d068d623d#text": Object { - "instructions": "Visit https://builder.io/fiddle/... for more details", - "value": "

I am slide 1

", - }, - "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#listItems.0.field1": Object { - "instructions": "Visit https://builder.io/fiddle/... for more details", - "value": "

text 1 value

", - }, - "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#listItems.1.field1": Object { - "instructions": "Visit https://builder.io/fiddle/... for more details", - "value": "

text 1.1 value

", - }, - "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#title.text": Object { - "instructions": "Visit https://builder.io/fiddle/... for more details", - "value": "

custom component subField input

", - }, -} -`; - exports[`getTranslateableFields from content to match snapshot 1`] = ` Object { "blocks.block-id#text": Object { @@ -385,14 +360,6 @@ Object { "instructions": "Visit https://builder.io/fiddle/... for more details", "value": "en-us headings!", }, - "blocks.button-localized-text-id#text": Object { - "instructions": "Button with pre-localized text", - "value": "Click Me!", - }, - "blocks.button-plain-text-id#text": Object { - "instructions": "Button with plain text", - "value": "Cute Baby", - }, "metadata.seo": Object { "instructions": "Visit https://builder.io/fiddle/... for more details", "value": Object { @@ -419,3 +386,28 @@ Object { }, } `; + +exports[`getTranslateableFields from carousel content and custom component with subFields to match snapshot 1`] = ` +Object { + "blocks.builder-06d3f6da74fb4054ad311afc1dda3675#text": Object { + "instructions": "Visit https://builder.io/fiddle/... for more details", + "value": "

I am slide second

", + }, + "blocks.builder-0a10ae48b6314221bbb7d06d068d623d#text": Object { + "instructions": "Visit https://builder.io/fiddle/... for more details", + "value": "

I am slide 1

", + }, + "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#listItems.0.field1": Object { + "instructions": "Visit https://builder.io/fiddle/... for more details", + "value": "

text 1 value

", + }, + "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#listItems.1.field1": Object { + "instructions": "Visit https://builder.io/fiddle/... for more details", + "value": "

text 1.1 value

", + }, + "blocks.builder-23e0618256ab40799ecf6504bc57fa1c#title.text": Object { + "instructions": "Visit https://builder.io/fiddle/... for more details", + "value": "

custom component subField input

", + }, +} +`; diff --git a/packages/utils/src/translation-helpers.ts b/packages/utils/src/translation-helpers.ts index e921d54af47..0b02d9b5434 100644 --- a/packages/utils/src/translation-helpers.ts +++ b/packages/utils/src/translation-helpers.ts @@ -220,27 +220,8 @@ export function getTranslateableFields( // blocks if (blocks) { - // Track how many levels deep we are inside excluded blocks - let excludedDepth = 0; - traverse(blocks).forEach(function (el) { - // Check if this element starts an exclusion zone - const startsExclusion = el && el.meta?.excludeFromTranslation; - if (startsExclusion) { - excludedDepth++; - } - - // After processing children, decrement the counter if this element started an exclusion - this.after(function () { - if (startsExclusion) { - excludedDepth--; - } - }); - - // Skip translation if we're inside an excluded block (excludedDepth > 0) - const isExcluded = excludedDepth > 0; - - if (this.key && el && el.meta?.localizedTextInputs && !isExcluded) { + if (this.key && el && el.meta?.localizedTextInputs) { const localizedTextInputs = el.meta.localizedTextInputs as string[]; if (localizedTextInputs && Array.isArray(localizedTextInputs)) { localizedTextInputs @@ -257,7 +238,7 @@ export function getTranslateableFields( }); } } - if (el && el.id && el.component?.name === 'Text' && !isExcluded) { + if (el && el.id && el.component?.name === 'Text' && !el.meta?.excludeFromTranslation) { const componentText = el.component.options.text; results[`blocks.${el.id}#text`] = { value: @@ -268,7 +249,7 @@ export function getTranslateableFields( }; } - if (el && el.id && el.component?.name === 'Core:Button' && !isExcluded) { + if (el && el.id && el.component?.name === 'Core:Button' && !el.meta?.excludeFromTranslation) { const componentText = el.component.options?.text; if (componentText) { const textValue = typeof componentText === 'string' @@ -283,7 +264,7 @@ export function getTranslateableFields( } } - if (el && el.id && el.component?.name === 'Symbol'&& !isExcluded) { + if (el && el.id && el.component?.name === 'Symbol') { const symbolInputs = Object.entries(el.component?.options?.symbol?.data) || []; if (symbolInputs.length) { const basePath = `blocks.${el.id}.symbolInput`; @@ -335,27 +316,8 @@ export function applyTranslation( } if (blocks) { - // Track how many levels deep we are inside excluded blocks - let excludedDepth = 0; - traverse(blocks).forEach(function (el) { - // Check if this element starts an exclusion zone - const startsExclusion = el && el.meta?.excludeFromTranslation; - if (startsExclusion) { - excludedDepth++; - } - - // After processing children, decrement the counter if this element started an exclusion - this.after(function () { - if (startsExclusion) { - excludedDepth--; - } - }); - - // Skip translation if we're inside an excluded block (excludedDepth > 0) - const isExcluded = excludedDepth > 0; - - if (el && el.id && el.component?.name === 'Symbol' && !isExcluded) { + if (el && el.id && el.component?.name === 'Symbol') { const symbolInputs = Object.entries(el.component?.options?.symbol?.data) || []; if (symbolInputs.length) { const transformedMeta = {}; @@ -406,7 +368,7 @@ export function applyTranslation( el && el.id && el.component?.name === 'Text' && - !isExcluded && + !el.meta?.excludeFromTranslation && translation[`blocks.${el.id}#text`] ) { const localizedValues = @@ -443,7 +405,7 @@ export function applyTranslation( el && el.id && el.component?.name === 'Core:Button' && - !isExcluded && + !el.meta?.excludeFromTranslation && translation[`blocks.${el.id}#text`] ) { const localizedValues = @@ -478,7 +440,7 @@ export function applyTranslation( } // custom components - if (el && el.id && el.meta?.localizedTextInputs && !isExcluded) { + if (el && el.id && el.meta?.localizedTextInputs) { // there's a localized input const keys = el.meta?.localizedTextInputs as string[]; let options = el.component.options; diff --git a/plugins/smartling/package-lock.json b/plugins/smartling/package-lock.json index e082064712f..b617ad37176 100644 --- a/plugins/smartling/package-lock.json +++ b/plugins/smartling/package-lock.json @@ -1,15 +1,15 @@ { "name": "@builder.io/plugin-smartling", - "version": "0.0.23-13", + "version": "0.0.23-11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@builder.io/plugin-smartling", - "version": "0.0.23-13", + "version": "0.0.23-11", "license": "MIT", "dependencies": { - "@builder.io/utils": "1.1.29", + "@builder.io/utils": "1.1.25-2", "fast-json-stable-stringify": "^2.1.0", "lodash": "^4.17.21", "object-hash": "^3.0.0", @@ -1487,9 +1487,9 @@ } }, "node_modules/@builder.io/utils": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/@builder.io/utils/-/utils-1.1.29.tgz", - "integrity": "sha512-NYP1ZEXyZouLf9zFUAH9Hw/uxkz8VU213YcZfOE5jSmOZtcfWMztZo1/8G6pJM112qSw6m85Jd+BLQIsz6UhpQ==", + "version": "1.1.26", + "resolved": "https://registry.npmjs.org/@builder.io/utils/-/utils-1.1.25.tgz", + "integrity": "sha512-o/XLSzPD4ZmJqUcsKNestu3J/Y8kFlsDd5odKDmVClu00dexJH27R6eEEoPkEF65V83wBVo4sDYGkIt4+4Fn0g==", "dependencies": { "@types/lodash": "^4.14.182", "lodash": "^4.17.21", @@ -23428,9 +23428,9 @@ } }, "@builder.io/utils": { - "version": "1.1.29", - "resolved": "https://registry.npmjs.org/@builder.io/utils/-/utils-1.1.29.tgz", - "integrity": "sha512-NYP1ZEXyZouLf9zFUAH9Hw/uxkz8VU213YcZfOE5jSmOZtcfWMztZo1/8G6pJM112qSw6m85Jd+BLQIsz6UhpQ==", + "version": "1.1.26", + "resolved": "https://registry.npmjs.org/@builder.io/utils/-/utils-1.1.25.tgz", + "integrity": "sha512-o/XLSzPD4ZmJqUcsKNestu3J/Y8kFlsDd5odKDmVClu00dexJH27R6eEEoPkEF65V83wBVo4sDYGkIt4+4Fn0g==", "requires": { "@types/lodash": "^4.14.182", "lodash": "^4.17.21", diff --git a/plugins/smartling/package.json b/plugins/smartling/package.json index 5261e7e1328..1e5c60ea997 100644 --- a/plugins/smartling/package.json +++ b/plugins/smartling/package.json @@ -1,6 +1,6 @@ { "name": "@builder.io/plugin-smartling", - "version": "0.0.23-13", + "version": "0.0.23-11", "description": "", "keywords": [], "main": "dist/plugin.system.js", @@ -125,7 +125,7 @@ "typescript": "^3.0.3" }, "dependencies": { - "@builder.io/utils": "1.1.29", + "@builder.io/utils": "1.1.26", "fast-json-stable-stringify": "^2.1.0", "lodash": "^4.17.21", "object-hash": "^3.0.0", diff --git a/plugins/smartling/src/plugin.tsx b/plugins/smartling/src/plugin.tsx index 7f6ce9db774..bc2cc995ed0 100644 --- a/plugins/smartling/src/plugin.tsx +++ b/plugins/smartling/src/plugin.tsx @@ -163,14 +163,6 @@ Builder.register('plugin', { advanced: false, requiredPermissions: ['admin'], }, - { - name: 'enableVisualContextCapture', - friendlyName: 'Enable Visual Context Capture', - type: 'boolean', - defaultValue: false, - helperText: 'Enable automatic visual context capture for translations', - requiredPermissions: ['admin'], - }, ], onSave: async actions => { const pluginPrivateKey = await appState.globalState.getPluginPrivateKey(pkg.name); @@ -468,7 +460,7 @@ const initializeSmartlingPlugin = async () => { } const element = selectedElements[0]; const isExcluded = element.meta?.get(transcludedMetaKey); - return !isExcluded; + return element.component?.name === 'Text' && !isExcluded; }, onClick(elements) { elements.forEach(el => el.meta.set('excludeFromTranslation', true)); @@ -484,85 +476,13 @@ const initializeSmartlingPlugin = async () => { } const element = selectedElements[0]; const isExcluded = element.meta?.get(transcludedMetaKey); - return isExcluded; + return element.component?.name === 'Text' && isExcluded; }, onClick(elements) { elements.forEach(el => el.meta.set('excludeFromTranslation', false)); }, }); - - registerContextMenuAction({ - label: 'Add String Instructions', - showIf(selectedElements) { - if (selectedElements.length !== 1) { - // todo maybe apply for multiple - return false; - } - const element = selectedElements[0]; - return element.meta?.get('instructions') === undefined; - }, - async onClick(elements) { - if (elements.length !== 1) { - // todo maybe apply for multiple - return false; - } - const instructions = await appState.dialogs.prompt({ - placeholderText: 'Enter string instructions for translation', - }); - if (instructions) { - elements[0].meta.set('instructions', instructions); - appState.snackBar.show('String instructions added to content'); - } - }, - }); - - registerContextMenuAction({ - label: 'Edit String Instructions', - showIf(selectedElements) { - if (selectedElements.length !== 1) { - // todo maybe apply for multiple - return false; - } - const element = selectedElements[0]; - return element.meta?.get('instructions') !== undefined; - }, - async onClick(elements) { - if (elements.length !== 1) { - // todo maybe apply for multiple - return false; - } - const element = elements[0]; - const instructions = element.meta?.get('instructions'); - if (instructions !== undefined) { - const newInstructions = await appState.dialogs.prompt({ - placeholderText: 'Enter new string instructions for translation', - defaultValue: instructions, - }); - if (newInstructions) { - element.meta.set('instructions', newInstructions); - appState.snackBar.show('String instructions updated'); - } - } - }, - }); - - registerContextMenuAction({ - label: 'Delete String Instructions', - showIf(selectedElements) { - if (selectedElements.length !== 1) { - // todo maybe apply for multiple - return false; - } - const element = selectedElements[0]; - return element.meta?.get('instructions') !== undefined; - }, - onClick(elements) { - elements[0].meta.delete('instructions'); - appState.snackBar.show('String instructions deleted'); - }, - }); - registerContentAction({ label: 'Add to translation job', showIf(content, model) {