00001 #!/usr/local/php512/bin/php 00002 <? 00003 /*************************************************************************** 00004 * Copyright (C) 2005 by Ferenc Veres * 00005 * lion@netngine.hu * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 if(empty($argc)) 00023 { 00024 exit; 00025 } 00026 include_once('config.inc.php'); 00027 include_once('lib/Common.php'); 00028 00029 $DB = NewADOConnection($CONFIG['db_software']); 00030 $DB->Connect($CONFIG['db_host'], $CONFIG['db_username'] , $CONFIG['db_password'], $CONFIG['db_database']); 00031 CacheIndexes(); 00032 00033 // EXAMPLE: To find a sentence 00034 00035 /* 00036 $findText = "Delete all"; 00037 $filterPercent = 80; 00038 00039 echo("SEEK: $findText\n"); 00040 00041 // Upload this sentence to our String class 00042 $myString = new TranslationString(); 00043 $translations = $myString->FindSimilar($findText, $filterPercent); 00044 00045 if(!empty($translations)) 00046 { 00047 foreach($translations as $id => $tr) 00048 { 00049 echo($tr["percent"]."%\n"); 00050 00051 foreach($tr["strings"] as $key => $str) 00052 { 00053 echo(" >>> '".$str->GetOriginal()."' === '".$str->GetTranslation()."'\n"); 00054 } 00055 } } 00056 else 00057 { 00058 echo("nothing similar, sorry.\n"); 00059 } 00060 00061 /**/ 00062 00063 // EXAMPLE: Using wordlist iterator 00064 00065 //include_once('TranslationWordList.php'); 00066 00067 //$wl = new TranslationWordList("hello kutya macska meg minden"); 00068 00069 //foreach($wl as $word) 00070 //{ 00071 // echo $word->GetID().":".$word->GetWord()." (".$word->GetCount()." db)\n"; 00072 //} 00073 00074 // EXAMPLE: Using project iterator 00075 00076 /* 00077 $parentProject = new TranslationProject(); 00078 if(!$parentProject->Load(0, "Xaraya", TranslationProject::$LocaleIDCache["hu_HU.utf-8"])) 00079 { 00080 throw new Exception("Error loading root project: Xaraya, hu_HU.utf-8."); 00081 } 00082 00083 $allProjects = new RecursiveIteratorIterator(new ProjectIterator($parentProject->GetID(), $parentProject->GetLocaleID()), RecursiveIteratorIterator::SELF_FIRST); 00084 00085 $iter = new ProjectIterator($parentProject->GetID(), $parentProject->GetLocaleID()); 00086 00087 foreach($allProjects as $project) 00088 { 00089 echo $project->GetID()." ".$project->GetName()."\n"; 00090 } 00091 /**/ 00092 00093 $it = new StringIterator(2452); 00094 foreach($it as $string) 00095 { 00096 echo $string->GetOriginal()."\n"; 00097 } 00098 ?>