From c98c4387a3bf3298f18e7d0197674a968a41a9de Mon Sep 17 00:00:00 2001 From: Peter Angelov Date: Thu, 5 Sep 2019 15:47:40 +0200 Subject: [PATCH] Add class="notranslate" to meta tag (#178) --- src/SEOTools/SEOMeta.php | 2 +- src/resources/config/seotools.php | 2 ++ tests/SEOTools/SEOMetaTest.php | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/SEOTools/SEOMeta.php b/src/SEOTools/SEOMeta.php index a714b10..dcb6145 100644 --- a/src/SEOTools/SEOMeta.php +++ b/src/SEOTools/SEOMeta.php @@ -151,7 +151,7 @@ public function generate($minify = false) $html = []; if ($title) { - $html[] = "$title"; + $html[] = Arr::get($this->config, 'add_notranslate_class', false) ? "$title" : "$title"; } if ($description) { diff --git a/src/resources/config/seotools.php b/src/resources/config/seotools.php index ff93cb5..f61ad97 100644 --- a/src/resources/config/seotools.php +++ b/src/resources/config/seotools.php @@ -27,6 +27,8 @@ 'pinterest' => null, 'yandex' => null, ], + + 'add_notranslate_class' => false, ], 'opengraph' => [ /* diff --git a/tests/SEOTools/SEOMetaTest.php b/tests/SEOTools/SEOMetaTest.php index a3646cf..4483e7f 100644 --- a/tests/SEOTools/SEOMetaTest.php +++ b/tests/SEOTools/SEOMetaTest.php @@ -289,4 +289,20 @@ public function test_utf8() $this->assertEquals($description, $this->seoMeta->getDescription()); $this->setRightAssertion($fullHeader); } + + public function test_it_can_add_notranslate_class_to_title() + { + $this->seoMeta = new SEOMeta(new \Illuminate\Config\Repository([ + 'add_notranslate_class' => true, + 'defaults' => [ + 'title' => 'It\'s Over 9000!', + 'description' => 'For those who helped create the Genki Dama', + ], + ])); + + $expected = "It's Over 9000!"; + $expected .= ""; + + $this->setRightAssertion($expected); + } }