19 include_once(
"lib/TranslationProject.php");
66 $langXml =
new DOMDocument();
67 if(!$langXml->load($fullName))
69 throw new Exception(
"Can't load language XML file.\n");
73 $document = $langXml->saveXML();
77 $xpath =
new DOMXPath($langXml);
78 $xpath->registerNamespace(
"m", $this->XmlNameSpace);
79 $entryNodes = $xpath->query(
"//m:translations/m:entry");
81 $projID = $thisProject->
GetID();
87 foreach ($entryNodes as $entry)
89 $origNodes = $xpath->query(
"m:string", $entry);
90 $transNodes = $xpath->query(
"m:translation", $entry);
92 if($origNodes->item(0)->nodeValue ==
"")
94 echo
"Empty Original node in the current file.\n";
102 $origNodes->item(0)->nodeValue,
104 $transNodes->item(0)->nodeValue,
109 $origNodes->item(0)->nodeValue =
"###${id}###";
110 $transNodes->item(0)->nodeValue =
"###${id}t###";
116 $skeleton = $langXml->saveXML();
118 $thisProject->
Save();
135 foreach($dirIterator as $file)
137 $fname = preg_replace(
'/.*\//',
'', $file->getFilename());
138 if($fname ==
"." || $fname ==
"..")
148 if(!$newProject->Load($parentProject->
GetID(), $fname, $parentProject->
GetLocaleID(),
false))
150 $newProject->CreateProject($root, $parentProject->
GetID(), $fname, $file->isDir(), $parentProject->
GetLocaleID());
159 if(preg_match(
"/\.xml$/", $fname))
162 echo
"process_file(".$file->getPathname().
")\n";
163 $this->
ImportFile($file->getPathname(), $newProject);
168 echo
"store file(".$file->getPathname().
")\n";
169 $newProject->SetDocument(file_get_contents($file->getPathname()));
177 $this->
ProcessDir($dirIterator->getChildren(), $newProject);
195 throw new Exception(
"ExportXaraya called with unknown locale name: $localeName");
202 $dir =
GetConfigVar(
'import_path').
"/".$localeName.
"/xml/";
205 throw new Exception(
"ExportXaraya using nonexisting directory: $dir");
208 $this->LocaleID = $localeID;
214 if(!$rootProject->LoadRoot($this->ProjectName, $this->LocaleID))
217 $rootProject->CreateRootProject($this->ProjectName, $this->LocaleID);
221 if(!$rootProject->Save())
223 throw new Exception(
"Cannot create root project for Xaraya.");
227 $dirIterator =
new RecursiveDirectoryIterator($dir);
228 $this->
ProcessDir($dirIterator, $rootProject);
ImportFile($fullName, TranslationProject $thisProject)
static ClearCache($localeID)
ProcessDir(RecursiveDirectoryIterator $dirIterator, TranslationProject $parentProject)