When translating text with BingTranslate, you might find that the translated text is simply wrong. With our Magento extension, you can simply translate the text through the Bing API first, then modify it and then store the modified translations in your Magento database. But when doing a lot of translations, sometimes you might want to make the same modifications over and over again. This tutorial explains how to add translation overrides for our Bing Translate extension.
With our Magento extension, you can translate text either through the extension API (model class bingtranslate/translate) or through the translate buttons in your Magento backend. Right before this translation is returned to you, an observable event content_translate_after is thrown which allows you to modify the translation automatically.
The extension itself uses this same trick so that the translated text can be changed: When the translation comes back from the BingTranslate API, the extension tries to locate a transliteration file to correct the mistakes of the translations. For this, it locates a file based on the original language and the destination language. All files are located in the folder app/design/adminhtml/default/default/translations:
For instance, if the original language is en (English) and the destination language is de (German), the following files are looked up:
The first file that is found is used for transliteration.
Let's work with an example here. Let's assume we are setting up a Magento shop with English as default language, while we also have a Store View for Dutch. Product descriptions are in English and need to be translated to Dutch. Now, one of the products might have a text like the following:
This is a cool extension
BingTranslate treats the word cool as if it was a reference to temperature, instead of being slang. And it treats the word extension as something like hair extension, instead of a software package. Obviously, this is wrong:
Dit is een koele uitbreiding
To make sure this text translates to the proper transliteration coole extensie, we'll create the following file:
And we'll add the following content to it:
"koele uitbreiding","coole extensie"
Next time, the BingTranslate API is used to translate this text, the text is first translated through the API, and next the Dutch phrase is replaced with the correct transliteration.