// 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(Loco::__('Cannot create MO file')); } else { if (file_exists($mopath) && !is_writable($mopath)) { throw new Exception(Loco::__('Cannot overwrite MO file')); } } // 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(Loco::__('Failed to compile MO file with %s, check your settings'), WHICH_MSGFMT)); } $response['compiled'] = $bytes; break; }