diff --git a/projects/plugins/jetpack/changelog/fix-google-embed-variations-translations b/projects/plugins/jetpack/changelog/fix-google-embed-variations-translations
new file mode 100644
index 0000000000000..1376a935e05a4
--- /dev/null
+++ b/projects/plugins/jetpack/changelog/fix-google-embed-variations-translations
@@ -0,0 +1,4 @@
+Significance: patch
+Type: other
+
+Google Docs Embed: fix non localized strings
diff --git a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/block.json b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/block.json
index 98ccd4615fbd6..71aef2b524317 100644
--- a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/block.json
+++ b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/block.json
@@ -24,37 +24,5 @@
"variation": {
"type": "string"
}
- },
- "variations": [
- {
- "name": "jetpack/google-docs",
- "isDefault": true,
- "title": "Google Docs",
- "description": "Embed a Google Document.",
- "icon": "",
- "keywords": [ "document", "gsuite", "doc" ],
- "attributes": { "variation": "jetpack/google-docs" },
- "isActive": [ "variation" ]
- },
- {
- "name": "jetpack/google-sheets",
- "isDefault": true,
- "title": "Google Sheets",
- "description": "Embed a Google Sheet.",
- "icon": "",
- "keywords": [ "sheet", "spreadsheet" ],
- "attributes": { "variation": "jetpack/google-sheets" },
- "isActive": [ "variation" ]
- },
- {
- "name": "jetpack/google-slides",
- "isDefault": true,
- "title": "Google Slides",
- "description": "Embed a Google Slides presentation.",
- "icon": "",
- "keywords": [ "slide", "presentation", "deck" ],
- "attributes": { "variation": "jetpack/google-slides" },
- "isActive": [ "variation" ]
- }
- ]
+ }
}
diff --git a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/edit.js b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/edit.js
index 38894082ee6be..f592560920b07 100644
--- a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/edit.js
+++ b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/edit.js
@@ -1,12 +1,10 @@
-import { getBlockIconProp } from '@automattic/jetpack-shared-extension-utils';
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody, SelectControl } from '@wordpress/components';
import { Fragment, useEffect } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
-import metadata from './block.json';
import Embed from './embed';
+import variations from './variations';
-const { variations } = metadata;
const docsVariation = variations?.find( v => v.name === 'jetpack/google-docs' );
const sheetsVariation = variations?.find( v => v.name === 'jetpack/google-sheets' );
const slidesVariation = variations?.find( v => v.name === 'jetpack/google-slides' );
@@ -14,21 +12,21 @@ const slidesVariation = variations?.find( v => v.name === 'jetpack/google-slides
const GOOGLE_DOCUMENT = {
type: 'document',
title: docsVariation?.title,
- icon: getBlockIconProp( docsVariation ),
+ icon: docsVariation.icon,
patterns: [ /^(http|https):\/\/(docs\.google.com)\/document\/d\/([A-Za-z0-9_-]+).*?$/i ],
};
const GOOGLE_SPREADSHEET = {
type: 'spreadsheets',
title: sheetsVariation?.title,
- icon: getBlockIconProp( sheetsVariation ),
+ icon: sheetsVariation.icon,
patterns: [ /^(http|https):\/\/(docs\.google.com)\/spreadsheets\/d\/([A-Za-z0-9_-]+).*?$/i ],
};
const GOOGLE_SLIDE = {
type: 'presentation',
title: slidesVariation?.title,
- icon: getBlockIconProp( slidesVariation ),
+ icon: slidesVariation.icon,
patterns: [ /^(http|https):\/\/(docs\.google.com)\/presentation\/d\/([A-Za-z0-9_-]+).*?$/i ],
};
diff --git a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/editor.js b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/editor.js
index 589de0a48312e..f78559f50f7e3 100644
--- a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/editor.js
+++ b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/editor.js
@@ -3,6 +3,7 @@ import metadata from './block.json';
import edit from './edit';
import save from './save'; // TODO: Replace
import transforms from './transforms';
+import variations from './variations';
import './editor.scss';
@@ -10,4 +11,5 @@ registerJetpackBlockFromMetadata( metadata, {
edit,
save,
transforms: transforms( metadata.name ),
+ variations,
} );
diff --git a/projects/plugins/jetpack/extensions/blocks/google-docs-embed/variations.js b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/variations.js
new file mode 100644
index 0000000000000..2315d7e59bb24
--- /dev/null
+++ b/projects/plugins/jetpack/extensions/blocks/google-docs-embed/variations.js
@@ -0,0 +1,42 @@
+import { getBlockIconProp } from '@automattic/jetpack-shared-extension-utils';
+import { __ } from '@wordpress/i18n';
+
+const variations = [
+ {
+ name: 'jetpack/google-docs',
+ isDefault: true,
+ title: __( 'Google Docs', 'jetpack' ),
+ description: __( 'Embed a Google Document.', 'jetpack' ),
+ icon: "",
+ keywords: [ __( 'document', 'jetpack' ), __( 'gsuite', 'jetpack' ), __( 'doc', 'jetpack' ) ],
+ attributes: { variation: 'jetpack/google-docs' },
+ isActive: [ 'variation' ],
+ },
+ {
+ name: 'jetpack/google-sheets',
+ isDefault: true,
+ title: __( 'Google Sheets', 'jetpack' ),
+ description: __( 'Embed a Google Sheet.', 'jetpack' ),
+ icon: "",
+ keywords: [ __( 'sheet', 'jetpack' ), __( 'spreadsheet', 'jetpack' ) ],
+ attributes: { variation: 'jetpack/google-sheets' },
+ isActive: [ 'variation' ],
+ },
+ {
+ name: 'jetpack/google-slides',
+ isDefault: true,
+ title: __( 'Google Slides', 'jetpack' ),
+ description: __( 'Embed a Google Slides presentation.', 'jetpack' ),
+ icon: "",
+
+ keywords: [
+ __( 'slide', 'jetpack' ),
+ __( 'presentation', 'jetpack' ),
+ __( 'deck', 'jetpack' ),
+ ],
+ attributes: { variation: 'jetpack/google-slides' },
+ isActive: [ 'variation' ],
+ },
+].map( variation => ( { ...variation, icon: getBlockIconProp( variation ) } ) );
+
+export default variations;
diff --git a/projects/plugins/jetpack/extensions/shared/register-jetpack-block.js b/projects/plugins/jetpack/extensions/shared/register-jetpack-block.js
index 08cb28adf0eb9..98eb2942ec32e 100644
--- a/projects/plugins/jetpack/extensions/shared/register-jetpack-block.js
+++ b/projects/plugins/jetpack/extensions/shared/register-jetpack-block.js
@@ -83,16 +83,6 @@ export function registerJetpackBlockFromMetadata( metadata, settings, childBlock
icon: getBlockIconProp( metadata ),
attributes: metadata.attributes || {},
};
- const { variations } = metadata;
-
- if ( Array.isArray( variations ) && variations.length > 0 ) {
- mergedSettings.variations = variations.map( variation => {
- return {
- ...variation,
- icon: getBlockIconProp( variation ),
- };
- } );
- }
return registerJetpackBlock( metadata, mergedSettings, childBlocks, prefix );
}