Skip to content
Snippets Groups Projects
Commit 4e138635 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Work on Google API v2

parent 5d5af4cd
No related branches found
No related tags found
No related merge requests found
......@@ -291,9 +291,11 @@ class autoTranslator
$src_text_to_translate=preg_replace('/'.preg_quote('\n\n').'/',' NNNNN ',$src_text_to_translate);
// Define GET URL v1
$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
// Define GET URL v2
// Example: "https://www.googleapis.com/language/translate/v2?key=".$this->apikey."&q=".urlencode($src_text_to_translate)."&source=".$src_lang."&target=".$dest_lang
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
// Example: https://www.googleapis.com/language/translate/v2?key=APIKEY&q=Setup%20area&source=en_US&target=fr_FR
// Send request
print "Url to translate: ".$url."\n";
......
......@@ -56,8 +56,8 @@ $dir=DOL_DOCUMENT_ROOT."/langs";
// Check parameters
if (! isset($argv[2])) {
print "Usage: ".$script_file." lang_code_src lang_code_dest|all [langfile.lang]\n";
print "Example: ".$script_file." en_US pt_PT\n";
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
print "Example: ".$script_file." en_US pt_PT 123456\n";
print "Rem: lang_code to use can be found on http://www.google.com/language_tools\n";
exit;
}
......@@ -65,11 +65,12 @@ if (! isset($argv[2])) {
// Show parameters
print 'Argument 1='.$argv[1]."\n";
print 'Argument 2='.$argv[2]."\n";
print 'Argument 3='.$argv[3]."\n";
$file='';
if (isset($argv[3]))
if (isset($argv[4]))
{
$file=$argv[3];
print 'Argument 3='.$argv[3]."\n";
$file=$argv[4];
print 'Argument 4='.$argv[4]."\n";
}
print 'Files will be generated/updated in directory '.$dir."\n";
......@@ -89,7 +90,7 @@ if ($argv[2] != 'all')
require_once(DOL_DOCUMENT_ROOT."/../dev/translation/autotranslator.class.php");
$langParser = new autoTranslator($argv[2],$argv[1],$dir,$file,$apikey);
$langParser = new autoTranslator($argv[2],$argv[1],$dir,$file,$argv[3]);
print "***** Finished *****\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment