3

When I install my language files (nl_NL) in my Magento 1.9.2.2 install, in the head section appears a JS tag that starts with:

var Translator = new Translate({...

What follows is a whole lot of strings in English and Dutch. In my opinion, this is bad for SEO.

My questions are:

  • is it really not good for SEO to have a whole lot of English and Dutch strings in the head?
  • how can I get rid of these strings (e.g. by creating a new, custom csv-file with translations)?

Hope there is anybody out there that can get me on track.

  • 2
    why would this be bad for SEO? It's just some javascript object. And if you remove this, your javascript messages will not be translated. Don't do it. – Marius Dec 7 '15 at 11:46
  • @Marius I have read about this being bad for SEO in an old thread here: link. One of the answers in this thread is from Magento-team and they say they are working on a solution. So now I am a bit confused although I tend to have more faith in your answers than in Magento's in general ;-) – Els den Iep Dec 7 '15 at 13:43
  • This time I didn't offer and answer. I was just curious how it is bad for seo because I have no idea and it does not make sense to me. I'm not saying it's not bad. But I have no idea how you can remove these without affecting your website. Like I said, the js messages will not be translated if you remove that. – Marius Dec 7 '15 at 13:48
  • My idea of it being bad for SEO and indexing in search engines is that there are all kinds of keywords in the head tag. Btw I thought your answer was: Don't remove it. Now I am confused again. Any suggestions? – Els den Iep Dec 7 '15 at 14:12
  • Sorry for the confusion. Yes, my answer is "don't remove it". If you do, all your javascript strings (alert messages, and other strings) will not be translated to Dutch. – Marius Dec 7 '15 at 14:14
5

I have to agree with you that this is minimally not 'good' for SEO. Magento has to make sure that inline JS is made to a bare minimun. That this is inline JS is just lazy programming.

We put this JS in a separate js file. To do this follow these instructions:

Go to a random page and find (chrome: right click > view source) the JS with this var:

var Translator = new Translate ({ "...other stuff.." });

Copy/paste this in translator.js in your theme js folder. (skin/frontend/package/theme/js)

In your template search for head.phtml > line 44:

<?php echo $this->helper('core/js')->getTranslatorScript() ?>

If you don't have head.phtml in your template copy paste it and remove the line above.

Now we have to add the translator.js to all the pages. Go to app/design/frontend/package/theme/layout/local.xml

Search IN the default tag for the reference with the name head. use this to add translator.js

<action method="addItem"><type>skin_js</type><file>js/translator.js</file></action>
  • Note that this approach is only useful if you don't use multiple languages. – Fabian Schmengler Jan 15 '16 at 15:36
  • @Wouter:Thanks Wouter (bedankt), in our case we do use multiple languages. – Els den Iep Feb 3 '16 at 13:32
  • @fschmengler: thanks for the additional comment. – Els den Iep Feb 3 '16 at 13:32
  • Well, you can do this for multiple languages also. We just have to make some small adjustments to the script. If I sort this out for you, do you accept the answer that I gave you? – Wouter Steenmeijer Feb 3 '16 at 14:50
  • @Wouter: Thanks. Sure I would accept your answer! As long as the solution is update proof and according to Magento development guidelines. – Els den Iep Feb 19 '16 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.