Skip to content

Instantly share code, notes, and snippets.

@yireo
Created November 3, 2013 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yireo/7287963 to your computer and use it in GitHub Desktop.
Save yireo/7287963 to your computer and use it in GitHub Desktop.
Magento script to translate a specific text using the Yireo GoogleTranslate extension
<?php
// Basic settings
$text = 'Hello World';
$source = 'en';
$destination = 'fr';
// Startup the application
require_once 'app/Mage.php';
Mage::app();
// Call upon the translator-model
$translator = Mage::getSingleton('googletranslate/translator');
$translation = $translator->translate($text, $source, $destination);
if(!empty($translation)) {
echo $translation."\n";
} else {
echo $translator->getApiError()."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment