Find out if you’re missing translations in Magento

Categorized Under: Magento No Commented

Let your visitors inform you about missing translations! This is for ‘exotic’ languages, from what I’ve seen, the main languages are well covered and up-to-date with new versions of Magento, but who knows…

Edit the file /app/code/core/Mage/Core/Model/Translate.php and go to the protected function _getTranslatedString($text, $code)
On the else branch add the code so that it looks like this:

else {
if(isset($_SERVER['REQUEST_URI']) && (strpos($_SERVER['REQUEST_URI'], '/admin') === false)) {
$f = fopen('var/translate-me.txt', 'a');
fwrite($f, date('Y-m-d H:i:s ').$text . ' |' . $_SERVER['HTTP_HOST'].  $_SERVER['REQUEST_URI'] ."\n");
fclose($f);
}
$translated = $text;
}

And then occasionally check the file /var/translate-me.txt for new texts to translate in the locale files. You will catch all untranslated texts, with the url of the page that generated the missing translation.

Notes:
- replace the “admin” check above with your own url to the admin interface
- var folder should be writable
- you will see untranslatable texts like category names, attributes, etc that are already localized but Magento tries to translate them anyway.

Leave a Reply