public function getLanguages($language_spec) { $languages = array(); $lang_handler = languages::getInstance("en"); if (strcmp($language_spec, "") == 0) { $language_spec = "zh-CN,cs-CZ,da-DK,nl-NL,en-GB,fr-FR,fi-FI,de-DE,el-GR,he-IL,ja-JA,ko-KR,it-IT,no-NO,pl-PL,pt-PT,ru-RU,es-ES,sv-SE"; } $list = explode(",", $language_spec); if (count($list) > 1) { $languages[] = array("name" => "Autodetect", "code" => "", "default" => 1); } foreach ($list as $language) { $name = $lang_handler->iso2Language($language); if (strlen($language) == 2) { $name = ereg_replace(" *\\(.+\\)", "", $name); # remove country name if not specified } $languages[] = array("name" => $name, "code" => $language, "default" => 0); } return $languages; }
public function doAction() { $lang_handler = languages::getInstance("en"); // log::doLog('REF SEGMENT: '.$this->ref_segment); if ($this->ref_segment == '') { $this->ref_segment = 0; } // CASMACAT extension start if ($this->casIsReplaying) { $data = getMoreSegmentsWithoutTranslation($this->jid, $this->password, $this->step, $this->ref_segment, $this->where); } else { $data = getMoreSegments($this->jid, $this->password, $this->step, $this->ref_segment, $this->where); } // CASMACAT extension end $first_not_translated_found = false; //log::doLog('REF SEGMENT: '.$this->ref_segment); // print_r($data); exit; foreach ($data as $i => $seg) { if ($this->where == 'before') { if ((double) $seg['sid'] >= (double) $this->ref_segment) { break; } } // remove this when tag management enabled // $seg['segment'] = $this->stripTagsFromSource($seg['segment']); if (empty($this->pname)) { $this->pname = $seg['pname']; } if (empty($this->last_opened_segment)) { $this->last_opened_segment = $seg['last_opened_segment']; } if (empty($this->cid)) { $this->cid = $seg['cid']; } if (empty($this->pid)) { $this->pid = $seg['pid']; } if (empty($this->tid)) { $this->tid = $seg['tid']; } if (empty($this->create_date)) { $this->create_date = $seg['create_date']; } if (empty($this->source_code)) { $this->source_code = $seg['source']; } if (empty($this->target_code)) { $this->target_code = $seg['target']; } if (empty($this->source)) { $s = explode("-", $seg['source']); $source = strtoupper($s[0]); $this->source = $source; } if (empty($this->target)) { $t = explode("-", $seg['target']); $target = strtoupper($t[0]); $this->target = $target; } $id_file = $seg['id_file']; $file_stats = CatUtils::getStatsForFile($id_file); if (!isset($this->data["{$id_file}"])) { $this->data["{$id_file}"]['jid'] = $seg['jid']; $this->data["{$id_file}"]["filename"] = $seg['filename']; $this->data["{$id_file}"]["mime_type"] = $seg['mime_type']; $this->data["{$id_file}"]['id_segment_start'] = $seg['id_segment_start']; $this->data["{$id_file}"]['id_segment_end'] = $seg['id_segment_end']; $this->data["{$id_file}"]['source'] = $lang_handler->iso2Language($seg['source']); $this->data["{$id_file}"]['target'] = $lang_handler->iso2Language($seg['target']); $this->data["{$id_file}"]['source_code'] = $seg['source']; $this->data["{$id_file}"]['target_code'] = $seg['target']; $this->data["{$id_file}"]['file_stats'] = $file_stats; $this->data["{$id_file}"]['segments'] = array(); } //if (count($this->data["$id_file"]['segments'])>100){continue;} $this->filetype_handler = new filetype($seg['mime_type']); unset($seg['id_file']); unset($seg['source']); unset($seg['target']); unset($seg['source_code']); unset($seg['target_code']); unset($seg['mime_type']); unset($seg['filename']); unset($seg['jid']); unset($seg['pid']); unset($seg['cid']); unset($seg['tid']); unset($seg['pname']); unset($seg['create_date']); unset($seg['id_segment_end']); unset($seg['id_segment_start']); // log::doLog('A'); $seg['segment'] = $this->filetype_handler->parse($seg['segment']); // ASKED. MARCO CONFIRMED: in the web interface do not show xliff_ext_prec_tags and xliff_ext_succ_tags // $seg['segment'] = $seg['xliff_ext_prec_tags'] . $seg['segment'].$seg['xliff_ext_succ_tags'] ; $seg['segment'] = CatUtils::rawxliff2view($seg['segment']); $seg['translation'] = CatUtils::rawxliff2view($seg['translation']); $seg['parsed_time_to_edit'] = $this->parse_time_to_edit($seg['time_to_edit']); $this->data["{$id_file}"]['segments'][] = $seg; } //log::doLog ($this->data); $this->result['data']['files'] = $this->data; $this->result['data']['where'] = $this->where; }
public function doAction() { $files_found = array(); $lang_handler = languages::getInstance("en"); // CASMACAT extension start // if ($this->casIsReplaying) { // $data = getSegmentsInfoWithoutTranslation($this->jid, $this->password, $this->start_from, $this->step); // } // else { $data = getSegmentsInfo($this->jid, $this->password); // } // CASMACAT extension end if (empty($data) or $data < 0) { $this->job_not_found = true; } // echo "<pre>"; // print_r ($data); // exit; $first_not_translated_found = false; foreach ($data as $i => $seg) { if (empty($this->pname)) { $this->pname = $seg['pname']; $this->downloadFileName = $seg['pname'] . ".zip"; // will be overwritten below in case of one file job } if (empty($this->last_opened_segment)) { $this->last_opened_segment = $seg['last_opened_segment']; } if (empty($this->cid)) { $this->cid = $seg['cid']; } if (empty($this->pid)) { $this->pid = $seg['pid']; } if (empty($this->tid)) { $this->tid = $seg['tid']; } if (empty($this->create_date)) { $this->create_date = $seg['create_date']; } if (empty($this->source_code)) { $this->source_code = $seg['source']; } if (empty($this->target_code)) { $this->target_code = $seg['target']; } if (empty($this->source)) { $s = explode("-", $seg['source']); $source = strtoupper($s[0]); $this->source = $source; } if (empty($this->target)) { $t = explode("-", $seg['target']); $target = strtoupper($t[0]); $this->target = $target; } $id_file = $seg['id_file']; $this->fid = $id_file; if (!isset($this->data["{$id_file}"])) { $files_found[] = $seg['filename']; $file_stats = CatUtils::getStatsForFile($id_file); $this->data["{$id_file}"]['jid'] = $seg['jid']; $this->data["{$id_file}"]["filename"] = $seg['filename']; $this->data["{$id_file}"]["mime_type"] = $seg['mime_type']; $this->data["{$id_file}"]['id_segment_start'] = $seg['id_segment_start']; $this->data["{$id_file}"]['id_segment_end'] = $seg['id_segment_end']; $this->data["{$id_file}"]['source'] = $lang_handler->iso2Language($seg['source']); $this->data["{$id_file}"]['target'] = $lang_handler->iso2Language($seg['target']); $this->data["{$id_file}"]['source_code'] = $seg['source']; $this->data["{$id_file}"]['target_code'] = $seg['target']; $this->data["{$id_file}"]['last_opened_segment'] = $seg['last_opened_segment']; $this->data["{$id_file}"]['file_stats'] = $file_stats; //$this->data["$id_file"]['segments'] = array(); } //if (count($this->data["$id_file"]['segments'])>100){continue;} $this->filetype_handler = new filetype($seg['mime_type']); unset($seg['id_file']); unset($seg['source']); unset($seg['target']); unset($seg['source_code']); unset($seg['target_code']); unset($seg['mime_type']); unset($seg['filename']); unset($seg['jid']); unset($seg['pid']); unset($seg['cid']); unset($seg['tid']); unset($seg['pname']); unset($seg['create_date']); unset($seg['id_segment_end']); unset($seg['id_segment_start']); unset($seg['last_opened_segment']); } if (empty($this->last_opened_segment)) { $this->last_opened_segment = getFirstSegmentId($this->jid, $this->password); log::doLog($this->last_opened_segment); } $this->job_stats = CatUtils::getStatsForJob($this->jid, $this->casIsReplaying); if (count($files_found) == 1) { $this->downloadFileName = $files_found[0]; } // CASMACAT start if ($this->casIsReplaying) { $this->initCfg = json_decode(fetchInitialConfig($this->jid, $this->fid)); log::doLog("CASMACAT: Initial config: " . print_r($this->initCfg, true)); } // CASMACAT end // echo "<pre>"; // print_r($this->data); // exit; }