diff --git a/src/Pass/FacebookNonIframeTransformPass.php b/src/Pass/FacebookNonIframeTransformPass.php index 49778e16..37200cd6 100644 --- a/src/Pass/FacebookNonIframeTransformPass.php +++ b/src/Pass/FacebookNonIframeTransformPass.php @@ -136,11 +136,18 @@ protected function getFacebookEmbedAttrs(DOMQuery $el) $height = $card ? self::DEFAULT_HEIGHT_WITH_CARD : self::DEFAULT_HEIGHT; } - return [ + $attrs = [ 'data-href' => $src, 'data-embed-as' => $embed_as, 'height' => $height, 'width' => $width ]; + + // Set locale if exists. + if (!empty($el->attr('data-locale'))) { + $attrs['data-locale'] = $el->attr('data-locale'); + } + + return $attrs; } } diff --git a/tests/test-data/fragment-html/facebook-non-iframe-fragment.html b/tests/test-data/fragment-html/facebook-non-iframe-fragment.html index 519996e8..661fa1bd 100644 --- a/tests/test-data/fragment-html/facebook-non-iframe-fragment.html +++ b/tests/test-data/fragment-html/facebook-non-iframe-fragment.html @@ -48,4 +48,13 @@ class="fb-xfbml-parse-ignore">Posted by Mark Zuckerberg on Wednesday, September 14, 2011 + + +
+
Posted by Mark Zuckerberg on Wednesday, + September 14, 2011
\ No newline at end of file diff --git a/tests/test-data/fragment-html/facebook-non-iframe-fragment.html.out b/tests/test-data/fragment-html/facebook-non-iframe-fragment.html.out index 05e0c793..8d3b66cf 100644 --- a/tests/test-data/fragment-html/facebook-non-iframe-fragment.html.out +++ b/tests/test-data/fragment-html/facebook-non-iframe-fragment.html.out @@ -11,6 +11,8 @@ + + ORIGINAL HTML --------------- Line 1:
@@ -64,6 +66,15 @@ Line 48: class="fb-xfbml-parse-ignore">Posted by Wednesday, Line 50: September 14, 2011 Line 51: +Line 52: +Line 53:
+Line 56:
Posted by Mark Zuckerberg on Wednesday, +Line 59: September 14, 2011
+Line 60:
Transformations made from HTML tags to AMP custom tags @@ -87,6 +98,9 @@ Transformations made from HTML tags to AMP custom tags
at line 46 ACTION TAKEN: div.fb-post facebook javascript sdk embed code was converted to the amp-facebook tag. +
at line 55 + ACTION TAKEN: div.fb-post facebook javascript sdk embed code was converted to the amp-facebook tag. + AMP-HTML Validation Issues and Fixes -------------------------------------