XarayaTranslationMemory  1.6
test.php
Go to the documentation of this file.
1 #!/usr/local/php512/bin/php
2 <?php
3 /***************************************************************************
4  * Copyright (C) 2005-2020 by Ferenc Veres *
5  * lion@netngine.hu *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  ***************************************************************************/
20 if(empty($argc))
21 {
22  exit;
23 }
24 include_once('config.inc.php');
25 include_once('lib/Common.php');
26 
27 $DB = NewADOConnection($CONFIG['db_software']);
28 $DB->Connect($CONFIG['db_host'], $CONFIG['db_username'] , $CONFIG['db_password'], $CONFIG['db_database']);
29 CacheIndexes();
30 
31 // EXAMPLE: To find a sentence
32 
33 /*
34  $findText = "Delete all";
35  $filterPercent = 80;
36 
37  echo("SEEK: $findText\n");
38 
39  // Upload this sentence to our String class
40  $myString = new TranslationString();
41  $translations = $myString->FindSimilar($findText, $filterPercent);
42 
43  if(!empty($translations))
44  {
45  foreach($translations as $id => $tr)
46  {
47  echo($tr["percent"]."%\n");
48 
49  foreach($tr["strings"] as $key => $str)
50  {
51  echo(" >>> '".$str->GetOriginal()."' === '".$str->GetTranslation()."'\n");
52  }
53  } }
54  else
55  {
56  echo("nothing similar, sorry.\n");
57  }
58 
59 /**/
60 
61 // EXAMPLE: Using wordlist iterator
62 
63 //include_once('TranslationWordList.php');
64 
65 //$wl = new TranslationWordList("hello kutya macska meg minden");
66 
67 //foreach($wl as $word)
68 //{
69 // echo $word->GetID().":".$word->GetWord()." (".$word->GetCount()." db)\n";
70 //}
71 
72 // EXAMPLE: Using project iterator
73 
74 /*
75 $parentProject = new TranslationProject();
76 if(!$parentProject->Load(0, "Xaraya", TranslationProject::$LocaleIDCache["hu_HU.utf-8"]))
77 {
78  throw new Exception("Error loading root project: Xaraya, hu_HU.utf-8.");
79 }
80 
81 $allProjects = new RecursiveIteratorIterator(new ProjectIterator($parentProject->GetID(), $parentProject->GetLocaleID()), RecursiveIteratorIterator::SELF_FIRST);
82 
83 $iter = new ProjectIterator($parentProject->GetID(), $parentProject->GetLocaleID());
84 
85 foreach($allProjects as $project)
86 {
87  echo $project->GetID()." ".$project->GetName()."\n";
88 }
89 /**/
90 
91 $it = new StringIterator(2452);
92 foreach($it as $string)
93 {
94  echo $string->GetOriginal()."\n";
95 }
96 ?>
CacheIndexes()
Definition: Common.php:94
$it
Definition: test.php:91
$DB
Definition: test.php:27
$CONFIG['db_software']
Definition: config.inc.php:24