Magento – Remove var Translator = new Translate from section

csvjavascriptlocalisationseo

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.

Best Answer

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>
Related Topic