-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat[plugin][smartling]: ENG-9736 visual context upload, exclude blocks, edit/add/delete string instructions #4218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
ee29448
f4bd2ef
b6bd777
89f0518
4544824
b2f99ba
5f13a8d
4a0e697
91b1cb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,21 @@ Builder.register('plugin', { | |
| advanced: false, | ||
| requiredPermissions: ['admin'], | ||
| }, | ||
| { | ||
| name: 'disableVisualContextCapture', | ||
| friendlyName: 'Disable Visual Context Capture', | ||
| type: 'boolean', | ||
| defaultValue: false, | ||
| helperText: 'Disable automatic visual context capture for translations', | ||
| requiredPermissions: ['admin'], | ||
| }, | ||
| { | ||
| name: 'contextOverrideOlderThanDays', | ||
| friendlyName: 'Context Override Older Than Days', | ||
| type: 'number', | ||
| helperText: 'Override context for content older than this number of days', | ||
| requiredPermissions: ['admin'], | ||
| }, | ||
| ], | ||
| onSave: async actions => { | ||
| const pluginPrivateKey = await appState.globalState.getPluginPrivateKey(pkg.name); | ||
|
|
@@ -460,7 +475,7 @@ const initializeSmartlingPlugin = async () => { | |
| } | ||
| const element = selectedElements[0]; | ||
| const isExcluded = element.meta?.get(transcludedMetaKey); | ||
| return element.component?.name === 'Text' && !isExcluded; | ||
| return !isExcluded; | ||
| }, | ||
| onClick(elements) { | ||
| elements.forEach(el => el.meta.set('excludeFromTranslation', true)); | ||
|
|
@@ -476,13 +491,85 @@ const initializeSmartlingPlugin = async () => { | |
| } | ||
| const element = selectedElements[0]; | ||
| const isExcluded = element.meta?.get(transcludedMetaKey); | ||
| return element.component?.name === 'Text' && isExcluded; | ||
| return 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) { | ||
|
||
| 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) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.