PK e„Í\È"Ø„E E loco-download.phpnu W+A„¶ getMessage(), 0 ); } if( ! $mo ){ throw new Exception( sprintf( __('Failed to compile MO file with %s, check your settings','loco-translate'), WHICH_MSGFMT ) ); } } // Fall back to in-built MO compiler - requires PO is parsed too else { $mo = LocoAdmin::msgfmt_native($po); } // exit with binary MO header('Content-Type: application/x-gettext-translation; charset=UTF-8', true ); header('Content-Length: '.strlen($mo), true ); header('Content-Disposition: attachment; filename='.$name, true ); echo $mo; exit(0); } catch( Exception $Ex ){ require dirname(__FILE__).'/loco-fatal.php'; } PK e„Í\imå´C C loco-posync.phpnu W+A„¶ get_domain(); if( $pot_path = $package->get_pot($domain) ){ $exp = LocoAdmin::parse_po( $pot_path ); if( ! $exp || ( 1 === count($exp) && '' === $exp[0]['source'] ) ){ // fall through to try source code } else { $pot = basename($pot_path); break; } } } // Extract from sources if( $exp = LocoAdmin::xgettext( $package, dirname($path) ) ){ $pot = ''; break; } throw new Exception( __('No strings could be extracted from source code','loco-translate') ); } // sync selected headers $headers = array(); if( '' === $exp[0]['source'] ){ $keep = array('Project-Id-Version','Language-Team','POT-Creation-Date','POT-Revision-Date'); $head = loco_parse_po_headers( $exp[0]['target'] ); $headers = array_intersect_key( $head->export(), array_flip($keep) ); /*/ add prefixed header keys that can't be included above foreach( $head as $key => $value ){ if( 0 === strpos($key, 'X-Poedit-' ) ){ $headers[$key] = $value; } }*/ $exp[0] = array(); } // sync ok. return compact( 'pot', 'exp', 'headers' ); PK e„Í\y¥ô loco-data.phpnu W+A„¶ array ( $locale => $data->export(), ), ); } throw new Exception( __('Invalid data posted to server','loco-translate'), 422 ); PK e„Í\ÜDÛW˜ ˜ loco-posave.phpnu W+A„¶ $bytes, 'filename' => basename($path), 'modified' => LocoAdmin::format_datetime( filemtime($path) ), ); // flush package from cache, so it's regenerated next list view with new stats $package->uncache(); // attempt to write MO file also, but may fail for numerous reasons. while( ! $ispot ){ try { // check target MO path before compiling $mopath = preg_replace( '/\.po$/', '.mo', $path ); if( ! file_exists($mopath) && ! is_writable( dirname($mopath) ) ){ throw new Exception( __('Cannot create MO file','loco-translate') ); } else if( file_exists($mopath) && ! is_writable($mopath) ){ throw new Exception( __('Cannot overwrite MO file','loco-translate') ); } // attempt to compile MO direct to file via shell if( $msgfmt = LocoAdmin::msgfmt_command() ){ try { $bytes = 0; loco_require('build/shell-compiled'); define( 'WHICH_MSGFMT', $msgfmt ); $mopath = loco_compile_mo_file( $path, $mopath ); $bytes = $mopath && file_exists($mopath) ? filesize($mopath) : 0; } catch( Exception $Ex ){ error_log( $Ex->getMessage(), 0 ); } if( ! $bytes ){ throw new Exception( sprintf( __('Failed to compile MO file with %s, check your settings','loco-translate'), WHICH_MSGFMT ) ); } $response['compiled'] = $bytes; break; } // Fall back to in-built MO compiler - requires PO is parsed too $mo = LocoAdmin::msgfmt_native($po); $bytes = file_put_contents( $mopath, $mo ); if( ! $bytes ){ throw new Exception( __('Failed to write MO file','loco-translate') ); } $response['compiled'] = $bytes; break; } catch( Exception $e ){ $response['compiled'] = $e->getMessage(); break; } } return $response; PK e„Í\ëDIН ¯ loco-fail.phpnu W+A„¶ getCode() or $status = 500; $message = $Ex->getMessage(); if( ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'] ) ){ $type = 'application/json; charset=UTF-8'; $body = json_encode( compact('status','message') ); } else { $type = 'text/html; charset=UTF-8'; $body = '