ReplaceVarInText($string); $string = str_replace("\r", ' ', $string); $string = str_replace("\n", ' ', $string); $string = str_replace('\\r', ' ', $string); $string = str_replace('\\n', ' ', $string); $string = str_replace(' ', '', $string); return $string; } function ReplaceCzText(string $string): string { $string = $this->Database->real_escape_string($string); $string = str_replace('$B', '\r\n', $string); $string = str_replace('$b', '\r\n', $string); $string = $this->ReplaceVarInText($string,''); return $string; } function NotCancel(string $string): bool { if (strpos($string,'') > -1) return false; else return true; } function my_trim(string $string): string { $string = addslashes($string); $string = str_replace("\n", '\r\\'."\n",$string); $string = str_replace("\r", '',$string); $string = str_replace("\\\\\\", '\\\\',$string); $string = str_replace("\\\\\\", '\\\\',$string); $string = str_replace("\\\\\\", '\\\\',$string); $string = str_replace("\\\\32", '\\32',$string); $string = str_replace('\\\\"', '\\"',$string); $string = str_replace('\\\\n', '\\n',$string); $string = str_replace('\\\\124', '\\124',$string); return $string; } function MakeLanguageFiles(): string { $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree(); $Output = ''; $this->LoadFilters(); $CreatedFileList = array(); $CreatedFileListCount = array(); if (!file_exists($this->TempDir.'CzWoW/')) mkdir($this->TempDir.'CzWoW/', 0777, true); $DbResult = $this->Database->query('SELECT `Group`.* FROM `ExportGroup` JOIN `Group` ON `Group`.`Id` = `ExportGroup`.`Group` WHERE `ExportGroup`.`Export`='.$this->Id.' AND `Group`.`TablePrefix` != ""'); while ($Group = $DbResult->fetch_assoc()) { // získání čísla verze pro export $ID = $this->Database->query('SELECT LastVersion FROM `Group` WHERE Id = '.$Group['Id']); $LastVersion = $ID->fetch_assoc(); if ($LastVersion['LastVersion'] < $this->ClientVersion['BuildNumber']) $ExportVersion = $LastVersion['LastVersion']; else $ExportVersion = ''; foreach ($TranslationTree[$Group['Id']]['Items'] as $Column) if ($Column['AddonFileName'] != '') { $this->AddProgress(1); if (!isset($CreatedFileListCount[$Column['AddonFileName']])) $CreatedFileListCount[$Column['AddonFileName']] = 0; $CreatedFileListCount[$Column['AddonFileName']]++; $FileIndex = $CreatedFileListCount[$Column['AddonFileName']]; $CreatedFileList[] = $Column['AddonFileName'].'_'.$FileIndex; $FileName = $this->TempDir.'CzWoW/'.$Column['AddonFileName'].'_'.$FileIndex.'.lua'; $Output .= $Column['AddonFileName'].': '; $i = 0; $Buffer = 'CZWOW_'.$Column['AddonFileName'].'_count='.$FileIndex.';CZWOW_'.$Column['AddonFileName'].'_'.$FileIndex.'={'; $TableTexts = array(); // old version // get version before $BuildNumber = $ExportVersion; if ($ExportVersion == '') $BuildNumber = $this->ClientVersion['BuildNumber']; $ID = $this->Database->query('SELECT `BuildNumber` FROM `ClientVersion` WHERE '. ' `Imported` = 1 AND `BuildNumber` < '.$BuildNumber.' ORDER BY `BuildNumber` DESC LIMIT 1'); if ($ID->num_rows > 0) { $ExportVersionOld = $ID->fetch_assoc(); $ExportVersionOld = $ExportVersionOld['BuildNumber']; $DbResult2 = $this->Database->query($this->BuildQuery($Group, $ExportVersionOld)); while ($Line = $DbResult2->fetch_assoc()) { $Text = $Line['En'.$Column['Column']]; if ($Text == null) $Text = ''; $en = trim($this->ReplaceEnText($Text)); $Text = $Line[$Column['Column']]; if ($Text == null) $Text = ''; $cz = $this->ReplaceCzText($Text); if (($en <> '') and ($cz <> '') and ($this->NotCancel($en))) { $TableTexts[$en] = $cz; } } } //last version $DbResult2 = $this->Database->query($this->BuildQuery($Group, $ExportVersion)); while ($Line = $DbResult2->fetch_assoc()) { $Text = $Line['En'.$Column['Column']]; if ($Text == null) $Text = ''; $en = trim($this->ReplaceEnText($Text)); $Text = $Line[$Column['Column']]; if ($Text == null) $Text = ''; $cz = $this->ReplaceCzText($Text); if (($en <> '') and ($cz <> '') and ($this->NotCancel($en))) { $TableTexts[$en] = $cz; } } foreach ($TableTexts as $key => $value) { $Buffer .= "\n".'["'.$key.'"]="'.$value.'",'; $i++; } $Buffer = $Buffer."\n};if not CZWOW_".$Column['AddonFileName']." then CZWOW_".$Column['AddonFileName']."=0; end; CZWOW_".$Column['AddonFileName']."=CZWOW_".$Column['AddonFileName']."+".$i.";\n"; file_put_contents($FileName, $Buffer); $Output .= 'Hotovo
'; } } // Generete list file of translated $CountFiles = 'CountFiles.lua'; $Buffer = ''; foreach ($CreatedFileList as $CreatedFile) { $Buffer .= 'CZWOW_'.str_replace('_','_count=',$CreatedFile).';'."\n"; } foreach ($TranslationTree as $Group) { foreach ($TranslationTree[$Group['Id']]['Items'] as $Column) { if (($Column['AddonFileName'] != '') and (!in_array($Column['AddonFileName'].'_1', $CreatedFileList))) { $Buffer .= 'CZWOW_'.$Column['AddonFileName'].'_count=0;'."\n"; } } } file_put_contents($this->TempDir.'CzWoW/'.$CountFiles, $Buffer); // Generate file Translates.xml $Buffer = ''."\n"; $Buffer .= '