', $Line); if(count($Parts) == 2) { $MsgId = substr(trim($Parts[0]), 1, -1); $MsgStr = trim($Parts[1]); if(substr($MsgStr, -1) == ',') $MsgStr = substr($MsgStr, 0, -1); $MsgStr = substr($MsgStr, 1, -1); $Dictionary[$MsgId] = $MsgStr; } } // Load PO file $PoDictionary = array(); $Source = file_get_contents($TranslatedFileName); $Source = explode("\n", $Source); foreach($Source as $Line) { $Command = substr($Line, 0, strpos($Line, ' ')); $Param = substr(trim(substr($Line, strpos($Line, ' '))), 1, -1); if($Command == 'msgid') $MsgId = $Param; else if($Command == 'msgstr') $PoDictionary[$MsgId] = $Param; } // Create Lang file $Output = array( " 'cs', 'Flag' => 'cz', 'Title' => 'Czech'", ");", "", '$LANG = array(', ); foreach($Dictionary as $Item => $Word2) { $Word = str_replace("\'", "'", $Word2); $Word = str_replace('"', '\"', $Word); if(array_key_exists($Word, $PoDictionary) and ($PoDictionary[$Word] != '')) $Line = " '".$Item."' => '".$PoDictionary[$Word]."',"; else $Line = " '".$Item."' => '".$Word2."',"; $Output[] = $Line; } $Output[] = ");"; $Output[] = "?>"; file_put_contents($LangFileName, implode("\r\n", $Output)); ?>