CC-1960: Internationalize Airtime / Support translations

-added gettext wrapper to all strings in models
This commit is contained in:
denise 2012-11-15 15:52:51 -05:00
parent d7495c6937
commit ef626a71b1
9 changed files with 102 additions and 101 deletions

View File

@ -30,7 +30,7 @@ class Application_Model_Auth
$e_link_port = $_SERVER['SERVER_PORT']; $e_link_port = $_SERVER['SERVER_PORT'];
$e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change'); $e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change');
$message = "Hi {$user->getDbLogin()}, \n\nClick this link to reset your password: "; $message = sprintf(_("Hi %s, \n\nClick this link to reset your password: "), $user->getDbLogin());
$message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}"; $message .= "{$e_link_protocol}://{$e_link_base}:{$e_link_port}{$e_link_path}";
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail()); $success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());

View File

@ -754,7 +754,7 @@ SQL;
try { try {
if (is_null($cueIn) && is_null($cueOut)) { if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"] = "Cue in and cue out are null."; $errArray["error"] = _("Cue in and cue out are null.");
return $errArray; return $errArray;
} }
@ -789,7 +789,7 @@ SQL;
); );
$result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column');
if ($result) { if ($result) {
$errArray["error"] = "Can't set cue out to be greater than file length."; $errArray["error"] = _("Can't set cue out to be greater than file length.");
return $errArray; return $errArray;
} }
@ -800,7 +800,7 @@ SQL;
); );
$result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column');
if ($result) { if ($result) {
$errArray["error"] = "Can't set cue in to be larger than cue out."; $errArray["error"] = _("Can't set cue in to be larger than cue out.");
return $errArray; return $errArray;
} }
@ -821,7 +821,7 @@ SQL;
); );
$result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column');
if ($result) { if ($result) {
$errArray["error"] = "Can't set cue in to be larger than cue out."; $errArray["error"] = _("Can't set cue in to be larger than cue out.");
return $errArray; return $errArray;
} }
@ -845,7 +845,7 @@ SQL;
); );
$result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column');
if ($result) { if ($result) {
$errArray["error"] = "Can't set cue out to be greater than file length."; $errArray["error"] = _("Can't set cue out to be greater than file length.");
return $errArray; return $errArray;
} }
@ -856,7 +856,7 @@ SQL;
); );
$result = Application_Common_Database::prepareAndExecute($sql, $params, 'column'); $result = Application_Common_Database::prepareAndExecute($sql, $params, 'column');
if ($result) { if ($result) {
$errArray["error"] = "Can't set cue out to be smaller than cue in."; $errArray["error"] = _("Can't set cue out to be smaller than cue in.");
return $errArray; return $errArray;
} }
@ -1204,32 +1204,32 @@ SQL;
public function getCriteria() public function getCriteria()
{ {
$criteriaOptions = array( $criteriaOptions = array(
0 => "Select criteria", 0 => _("Select criteria"),
"album_title" => "Album", "album_title" => _("Album"),
"bit_rate" => "Bit Rate (Kbps)", "bit_rate" => _("Bit Rate (Kbps)"),
"bpm" => "BPM", "bpm" => _("BPM"),
"composer" => "Composer", "composer" => _("Composer"),
"conductor" => "Conductor", "conductor" => _("Conductor"),
"copyright" => "Copyright", "copyright" => _("Copyright"),
"artist_name" => "Creator", "artist_name" => _("Creator"),
"encoded_by" => "Encoded By", "encoded_by" => _("Encoded By"),
"genre" => "Genre", "genre" => _("Genre"),
"isrc_number" => "ISRC", "isrc_number" => _("ISRC"),
"label" => "Label", "label" => _("Label"),
"language" => "Language", "language" => _("Language"),
"mtime" => "Last Modified", "mtime" => _("Last Modified"),
"lptime" => "Last Played", "lptime" => _("Last Played"),
"length" => "Length", "length" => _("Length"),
"mime" => "Mime", "mime" => _("Mime"),
"mood" => "Mood", "mood" => _("Mood"),
"owner_id" => "Owner", "owner_id" => _("Owner"),
"replay_gain" => "Replay Gain", "replay_gain" => _("Replay Gain"),
"sample_rate" => "Sample Rate (kHz)", "sample_rate" => _("Sample Rate (kHz)"),
"track_title" => "Title", "track_title" => _("Title"),
"track_number" => "Track Number", "track_number" => _("Track Number"),
"utime" => "Uploaded", "utime" => _("Uploaded"),
"info_url" => "Website", "info_url" => _("Website"),
"year" => "Year" "year" => _("Year")
); );
// Load criteria from db // Load criteria from db

View File

@ -157,15 +157,15 @@ SQL;
$diff = strlen($dir) - strlen($p_path); $diff = strlen($dir) - strlen($p_path);
if ($diff == 0) { if ($diff == 0) {
if ($dir == $p_path) { if ($dir == $p_path) {
throw new NestedDirectoryException("'$p_path' is already watched."); throw new NestedDirectoryException(sprintf(_("%s is already watched."), $p_path));
} }
} elseif ($diff > 0) { } elseif ($diff > 0) {
if (self::isAncestorDir($p_path, $dir)) { if (self::isAncestorDir($p_path, $dir)) {
throw new NestedDirectoryException("'$p_path' contains nested watched directory: '$dir'"); throw new NestedDirectoryException(sprintf(_("%s contains nested watched directory: %s"), $p_path, $dir));
} }
} else { /* diff < 0*/ } else { /* diff < 0*/
if (self::isAncestorDir($dir, $p_path)) { if (self::isAncestorDir($dir, $p_path)) {
throw new NestedDirectoryException("'$p_path' is nested within existing watched directory: '$dir'"); throw new NestedDirectoryException(sprintf(_("%s is nested within existing watched directory: %s"), $p_path, $dir));
} }
} }
} }
@ -186,7 +186,7 @@ SQL;
public static function addDir($p_path, $p_type, $userAddedWatchedDir=true, $nestedWatch=false) public static function addDir($p_path, $p_type, $userAddedWatchedDir=true, $nestedWatch=false)
{ {
if (!is_dir($p_path)) { if (!is_dir($p_path)) {
return array("code"=>2, "error"=>"'$p_path' is not a valid directory."); return array("code"=>2, "error"=>sprintf(_("%s is not a valid directory."), $p_path));
} }
$real_path = Application_Common_OsPath::normpath($p_path)."/"; $real_path = Application_Common_OsPath::normpath($p_path)."/";
if ($real_path != "/") { if ($real_path != "/") {
@ -227,7 +227,8 @@ SQL;
return array("code"=>1, "error"=>"$msg"); return array("code"=>1, "error"=>"$msg");
} catch (Exception $e) { } catch (Exception $e) {
return array("code"=>1, "error"=>"'$p_path' is already set as the current storage dir or in the watched folders list"); return array("code"=>1,
"error"=>sprintf(_("%s is already set as the current storage dir or in the watched folders list"), $p_path));
} }
} }
@ -359,7 +360,7 @@ SQL;
// path should always ends with trailing '/' // path should always ends with trailing '/'
$p_dir = Application_Common_OsPath::normpath($p_dir)."/"; $p_dir = Application_Common_OsPath::normpath($p_dir)."/";
if (!is_dir($p_dir)) { if (!is_dir($p_dir)) {
return array("code"=>2, "error"=>"'$p_dir' is not a valid directory."); return array("code"=>2, "error"=>sprintf(_("%s is not a valid directory."), $p_dir));
} elseif (Application_Model_Preference::GetImportTimestamp()+10 > time()) { } elseif (Application_Model_Preference::GetImportTimestamp()+10 > time()) {
return array("code"=>3, "error"=>"Airtime is currently importing files. Please wait until this is complete before changing the storage directory."); return array("code"=>3, "error"=>"Airtime is currently importing files. Please wait until this is complete before changing the storage directory.");
} }
@ -376,7 +377,8 @@ SQL;
return array("code"=>0); return array("code"=>0);
} else { } else {
return array("code"=>1, "error"=>"'$p_dir' is already set as the current storage dir or in the watched folders list."); return array("code"=>1,
"error"=>sprintf(_("%s is already set as the current storage dir or in the watched folders list."), $p_dir));
} }
} }
@ -419,7 +421,7 @@ SQL;
} }
$dir = Application_Model_MusicDir::getDirByPath($p_dir); $dir = Application_Model_MusicDir::getDirByPath($p_dir);
if (is_null($dir)) { if (is_null($dir)) {
return array("code"=>1, "error"=>"'$p_dir' doesn't exist in the watched list."); return array("code"=>1, "error"=>sprintf(_("%s doesn't exist in the watched list."), $p_dir));
} else { } else {
$dir->remove($userAddedWatchedDir); $dir->remove($userAddedWatchedDir);
$data = array(); $data = array();

View File

@ -721,7 +721,7 @@ SQL;
try { try {
if (is_null($cueIn) && is_null($cueOut)) { if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"] = "Cue in and cue out are null."; $errArray["error"] = _("Cue in and cue out are null.");
return $errArray; return $errArray;
} }
@ -751,14 +751,14 @@ SQL;
$sql = "SELECT :cueIn::INTERVAL > :cueOut::INTERVAL"; $sql = "SELECT :cueIn::INTERVAL > :cueOut::INTERVAL";
if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':cueOut'=>$cueOut), 'column')) { if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':cueOut'=>$cueOut), 'column')) {
$errArray["error"] = "Can't set cue in to be larger than cue out."; $errArray["error"] = _("Can't set cue in to be larger than cue out.");
return $errArray; return $errArray;
} }
$sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL";
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) {
$errArray["error"] = "Can't set cue out to be greater than file length."; $errArray["error"] = _("Can't set cue out to be greater than file length.");
return $errArray; return $errArray;
} }
@ -774,7 +774,7 @@ SQL;
$sql = "SELECT :cueIn::INTERVAL > :oldCueOut::INTERVAL"; $sql = "SELECT :cueIn::INTERVAL > :oldCueOut::INTERVAL";
if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column')) { if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column')) {
$errArray["error"] = "Can't set cue in to be larger than cue out."; $errArray["error"] = _("Can't set cue in to be larger than cue out.");
return $errArray; return $errArray;
} }
@ -792,14 +792,14 @@ SQL;
$sql = "SELECT :cueOut::INTERVAL < :oldCueIn::INTERVAL"; $sql = "SELECT :cueOut::INTERVAL < :oldCueIn::INTERVAL";
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn), 'column')) { if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn), 'column')) {
$errArray["error"] = "Can't set cue out to be smaller than cue in."; $errArray["error"] = _("Can't set cue out to be smaller than cue in.");
return $errArray; return $errArray;
} }
$sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL";
if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) {
$errArray["error"] = "Can't set cue out to be greater than file length."; $errArray["error"] = _("Can't set cue out to be greater than file length.");
return $errArray; return $errArray;
} }

View File

@ -79,12 +79,12 @@ class Application_Model_Scheduler
//an item has been deleted //an item has been deleted
if (count($schedIds) !== count($schedItems)) { if (count($schedIds) !== count($schedItems)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (sched mismatch)"); throw new OutDatedScheduleException(_("The schedule you're viewing is out of date! (sched mismatch)"));
} }
//a show has been deleted //a show has been deleted
if (count($instanceIds) !== count($showInstances)) { if (count($instanceIds) !== count($showInstances)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date! (instance mismatch)"); throw new OutDatedScheduleException(_("The schedule you're viewing is out of date! (instance mismatch)"));
} }
foreach ($schedItems as $schedItem) { foreach ($schedItems as $schedItem) {
@ -92,7 +92,7 @@ class Application_Model_Scheduler
$instance = $schedItem->getCcShowInstances($this->con); $instance = $schedItem->getCcShowInstances($this->con);
if (intval($schedInfo[$id]) !== $instance->getDbId()) { if (intval($schedInfo[$id]) !== $instance->getDbId()) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!"); throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!"));
} }
} }
@ -102,24 +102,24 @@ class Application_Model_Scheduler
$show = $instance->getCcShow($this->con); $show = $instance->getCcShow($this->con);
if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) { if ($this->checkUserPermissions && $this->user->canSchedule($show->getDbId()) === false) {
throw new Exception("You are not allowed to schedule show {$show->getDbName()}."); throw new Exception(sprintf(_("You are not allowed to schedule show %s."), $show->getDbName()));
} }
if ($instance->getDbRecord()) { if ($instance->getDbRecord()) {
throw new Exception("You cannot add files to recording shows."); throw new Exception(_("You cannot add files to recording shows."));
} }
$showEndEpoch = floatval($instance->getDbEnds("U.u")); $showEndEpoch = floatval($instance->getDbEnds("U.u"));
if ($showEndEpoch < $nowEpoch) { if ($showEndEpoch < $nowEpoch) {
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled."); throw new OutDatedScheduleException(sprintf(_("The show %s is over and cannot be scheduled."), $show->getDbName()));
} }
$ts = intval($instanceInfo[$id]); $ts = intval($instanceInfo[$id]);
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0; $lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
if ($ts < $lastSchedTs) { if ($ts < $lastSchedTs) {
Logging::info("ts {$ts} last sched {$lastSchedTs}"); Logging::info("ts {$ts} last sched {$lastSchedTs}");
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!"); throw new OutDatedScheduleException(sprintf(_("The show %s has been previously updated!"), $show->getDbName()));
} }
} }
} }
@ -138,7 +138,7 @@ class Application_Model_Scheduler
$file = CcFilesQuery::create()->findPK($id, $this->con); $file = CcFilesQuery::create()->findPK($id, $this->con);
if (is_null($file) || !$file->visible()) { if (is_null($file) || !$file->visible()) {
throw new Exception("A selected File does not exist!"); throw new Exception(_("A selected File does not exist!"));
} else { } else {
$data = $this->fileInfo; $data = $this->fileInfo;
$data["id"] = $id; $data["id"] = $id;
@ -219,7 +219,7 @@ class Application_Model_Scheduler
$stream = CcWebstreamQuery::create()->findPK($id, $this->con); $stream = CcWebstreamQuery::create()->findPK($id, $this->con);
if (is_null($stream) /* || !$file->visible() */) { if (is_null($stream) /* || !$file->visible() */) {
throw new Exception("A selected File does not exist!"); throw new Exception(_("A selected File does not exist!"));
} else { } else {
$data = $this->fileInfo; $data = $this->fileInfo;
$data["id"] = $id; $data["id"] = $id;
@ -343,7 +343,7 @@ class Application_Model_Scheduler
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
if (is_null($instance)) { if (is_null($instance)) {
throw new OutDatedScheduleException("The schedule you're viewing is out of date!"); throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!"));
} }
$itemStartDT = $instance->getDbStarts(null); $itemStartDT = $instance->getDbStarts(null);

View File

@ -177,7 +177,7 @@ SQL;
$con = Propel::getConnection(); $con = Propel::getConnection();
if ($deltaDay > 0) { if ($deltaDay > 0) {
return "Shows can have a max length of 24 hours."; return _("Shows can have a max length of 24 hours.");
} }
$utc = new DateTimeZone("UTC"); $utc = new DateTimeZone("UTC");
@ -208,7 +208,7 @@ SQL;
$newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin); $newEndsDateTime = Application_Model_ShowInstance::addDeltas($endsDateTime, $deltaDay, $deltaMin);
if ($newEndsDateTime->getTimestamp() < $nowDateTime->getTimestamp()) { if ($newEndsDateTime->getTimestamp() < $nowDateTime->getTimestamp()) {
return "End date/time cannot be in the past"; return _("End date/time cannot be in the past");
} }
//convert our new starts/ends to UTC. //convert our new starts/ends to UTC.
@ -219,8 +219,8 @@ SQL;
$newStartsDateTime, $newEndsDateTime, true, $si->getDbId()); $newStartsDateTime, $newEndsDateTime, true, $si->getDbId());
if ($overlapping) { if ($overlapping) {
return "Cannot schedule overlapping shows.\nNote: Resizing a repeating show ". return _("Cannot schedule overlapping shows.\nNote: Resizing a repeating show ".
"affects all of its repeats."; "affects all of its repeats.");
} }
} }

View File

@ -242,7 +242,7 @@ SQL;
public function moveShow($deltaDay, $deltaMin) public function moveShow($deltaDay, $deltaMin)
{ {
if ($this->getShow()->isRepeating()) { if ($this->getShow()->isRepeating()) {
return "Can't drag and drop repeating shows"; return _("Can't drag and drop repeating shows");
} }
$today_timestamp = time(); $today_timestamp = time();
@ -250,7 +250,7 @@ SQL;
$endsDateTime = new DateTime($this->getShowInstanceEnd(), new DateTimeZone("UTC")); $endsDateTime = new DateTime($this->getShowInstanceEnd(), new DateTimeZone("UTC"));
if ($today_timestamp > $startsDateTime->getTimestamp()) { if ($today_timestamp > $startsDateTime->getTimestamp()) {
return "Can't move a past show"; return _("Can't move a past show");
} }
//the user is moving the show on the calendar from the perspective of local time. //the user is moving the show on the calendar from the perspective of local time.
@ -267,13 +267,13 @@ SQL;
$newEndsDateTime->setTimezone(new DateTimeZone("UTC")); $newEndsDateTime->setTimezone(new DateTimeZone("UTC"));
if ($today_timestamp > $newStartsDateTime->getTimestamp()) { if ($today_timestamp > $newStartsDateTime->getTimestamp()) {
return "Can't move show into past"; return _("Can't move show into past");
} }
//check if show is overlapping //check if show is overlapping
$overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime, $newEndsDateTime, true, $this->getShowInstanceId()); $overlapping = Application_Model_Schedule::checkOverlappingShows($newStartsDateTime, $newEndsDateTime, true, $this->getShowInstanceId());
if ($overlapping) { if ($overlapping) {
return "Cannot schedule overlapping shows"; return _("Cannot schedule overlapping shows");
} }
if ($this->isRecorded()) { if ($this->isRecorded()) {
@ -287,7 +287,7 @@ SQL;
->find(); ->find();
if (count($rebroadcasts) > 0) { if (count($rebroadcasts) > 0) {
return "Can't move a recorded show less than 1 hour before its rebroadcasts."; return _("Can't move a recorded show less than 1 hour before its rebroadcasts.");
} }
} }
@ -300,14 +300,14 @@ SQL;
catch (Exception $e) { catch (Exception $e) {
$this->_showInstance->delete(); $this->_showInstance->delete();
return "Show was deleted because recorded show does not exist!"; return _("Show was deleted because recorded show does not exist!");
} }
$recordEndDateTime = new DateTime($recordedShow->getShowInstanceEnd(), new DateTimeZone("UTC")); $recordEndDateTime = new DateTime($recordedShow->getShowInstanceEnd(), new DateTimeZone("UTC"));
$newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60); $newRecordEndDateTime = self::addDeltas($recordEndDateTime, 0, 60);
if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) { if ($newStartsDateTime->getTimestamp() < $newRecordEndDateTime->getTimestamp()) {
return "Must wait 1 hour to rebroadcast."; return _("Must wait 1 hour to rebroadcast.");
} }
} }
@ -339,7 +339,7 @@ SQL;
$ends = $this->getShowInstanceEnd(); $ends = $this->getShowInstanceEnd();
if (strtotime($today_timestamp) > strtotime($starts)) { if (strtotime($today_timestamp) > strtotime($starts)) {
return "can't resize a past show"; return _("can't resize a past show");
} }
//$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'"; //$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
@ -361,7 +361,7 @@ SQL;
if (count($overlap) > 0) { if (count($overlap) > 0) {
// TODO : fix ghetto error handling -- RG // TODO : fix ghetto error handling -- RG
return "Should not overlap shows"; return _("Should not overlap shows");
} }
} }
//with overbooking no longer need to check already scheduled content still fits. //with overbooking no longer need to check already scheduled content still fits.

View File

@ -794,14 +794,14 @@ SQL;
// ugly // ugly
if ($type == "au") { if ($type == "au") {
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
$row['image'] = '<img title="Track preview" src="'.$baseUrl.'/css/images/icon_audioclip.png">'; $row['image'] = '<img title="'._("Track preview").'" src="'.$baseUrl.'/css/images/icon_audioclip.png">';
} elseif ($type == "pl") { } elseif ($type == "pl") {
$row['image'] = '<img title="Playlist preview" src="'.$baseUrl.'/css/images/icon_playlist.png">'; $row['image'] = '<img title="'._("Playlist preview").'" src="'.$baseUrl.'/css/images/icon_playlist.png">';
} elseif ($type == "st") { } elseif ($type == "st") {
$row['audioFile'] = $row['id']; $row['audioFile'] = $row['id'];
$row['image'] = '<img title="Webstream preview" src="'.$baseUrl.'/css/images/icon_webstream.png">'; $row['image'] = '<img title="'._("Webstream preview").'" src="'.$baseUrl.'/css/images/icon_webstream.png">';
} elseif ($type == "bl") { } elseif ($type == "bl") {
$row['image'] = '<img title="Smart Block" src="'.$baseUrl.'/css/images/icon_smart-block.png">'; $row['image'] = '<img title="'._("Smart Block").'" src="'.$baseUrl.'/css/images/icon_smart-block.png">';
} }
} }
@ -853,7 +853,7 @@ SQL;
closedir($dir); closedir($dir);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": _("Failed to open temp directory.")}, "id" : "id"}');
// Look for the content type header // Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"])) if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
@ -880,14 +880,14 @@ SQL;
while ($buff = fread($in, 4096)) while ($buff = fread($in, 4096))
fwrite($out, $buff); fwrite($out, $buff);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
fclose($out); fclose($out);
unlink($_FILES['file']['tmp_name']); unlink($_FILES['file']['tmp_name']);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": _("Failed to open output stream.")}, "id" : "id"}');
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": _("Failed to move uploaded file.")}, "id" : "id"}');
} else { } else {
// Open temp file // Open temp file
$out = fopen($tempFilePath, $chunk == 0 ? "wb" : "ab"); $out = fopen($tempFilePath, $chunk == 0 ? "wb" : "ab");
@ -899,11 +899,11 @@ SQL;
while ($buff = fread($in, 4096)) while ($buff = fread($in, 4096))
fwrite($out, $buff); fwrite($out, $buff);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": _("Failed to open input stream.")}, "id" : "id"}');
fclose($out); fclose($out);
} else } else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": _("Failed to open output stream.")}, "id" : "id"}');
} }
return $tempFilePath; return $tempFilePath;
@ -934,7 +934,7 @@ SQL;
if (!mkdir($stor."/organize", 0777)) { if (!mkdir($stor."/organize", 0777)) {
return array( return array(
"code" => 109, "code" => 109,
"message" => "Failed to create 'organize' directory."); "message" => _("Failed to create 'organize' directory."));
} }
} }
@ -947,17 +947,17 @@ SQL;
$freeSpace = disk_free_space($stor); $freeSpace = disk_free_space($stor);
return array("code" => 107, return array("code" => 107,
"message" => "The file was not uploaded, there is "message" => sprintf(_("The file was not uploaded, there is "
".$freeSpace."MB of disk space left and the file you are ."%s MB of disk space left and the file you are "
uploading has a size of ".$fileSize."MB."); ."uploading has a size of %s MB."), $freeSpace, $fileSize));
} }
// Check if liquidsoap can play this file // Check if liquidsoap can play this file
if (!self::liquidsoapFilePlayabilityTest($audio_file)) { if (!self::liquidsoapFilePlayabilityTest($audio_file)) {
return array( return array(
"code" => 110, "code" => 110,
"message" => "This file appears to be corrupted and will not "message" => _("This file appears to be corrupted and will not "
be added to media library."); ."be added to media library."));
} }
// Did all the checks for real, now trying to copy // Did all the checks for real, now trying to copy
@ -992,10 +992,9 @@ SQL;
return array( return array(
"code" => 108, "code" => 108,
"message" => " "message" => _("The file was not uploaded, this error can occur if the computer "
The file was not uploaded, this error can occur if the computer ."hard drive does not have enough disk space or the stor "
hard drive does not have enough disk space or the stor ."directory does not have correct write permissions."));
directory does not have correct write permissions.");
} }
// Now that we successfully added this file, we will add another tag // Now that we successfully added this file, we will add another tag
// file that will identify the user that owns it // file that will identify the user that owns it

View File

@ -154,12 +154,12 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
if ($totalMinutes == 0) { if ($totalMinutes == 0) {
$valid['length'][0] = false; $valid['length'][0] = false;
$valid['length'][1] = 'Length needs to be greater than 0 minutes'; $valid['length'][1] = _('Length needs to be greater than 0 minutes');
} }
} else { } else {
$valid['length'][0] = false; $valid['length'][0] = false;
$valid['length'][1] = 'Length should be of form "00h 00m"'; $valid['length'][1] = _('Length should be of form "00h 00m"');
} }
$url = $parameters["url"]; $url = $parameters["url"];
@ -172,16 +172,16 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$mediaUrl = null; $mediaUrl = null;
if ($result == 0) { if ($result == 0) {
$valid['url'][0] = false; $valid['url'][0] = false;
$valid['url'][1] = 'URL should be of form "http://domain"'; $valid['url'][1] = _('URL should be of form "http://domain"');
} elseif (strlen($url) > 512) { } elseif (strlen($url) > 512) {
$valid['url'][0] = false; $valid['url'][0] = false;
$valid['url'][1] = 'URL should be 512 characters or less'; $valid['url'][1] = _('URL should be 512 characters or less');
} else { } else {
try { try {
list($mime, $content_length_found) = self::discoverStreamMime($url); list($mime, $content_length_found) = self::discoverStreamMime($url);
if (is_null($mime)) { if (is_null($mime)) {
throw new Exception("No MIME type found for webstream."); throw new Exception(_("No MIME type found for webstream."));
} }
$mediaUrl = self::getMediaUrl($url, $mime, $content_length_found); $mediaUrl = self::getMediaUrl($url, $mime, $content_length_found);
@ -197,7 +197,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$name = $parameters["name"]; $name = $parameters["name"];
if (strlen($name) == 0) { if (strlen($name) == 0) {
$valid['name'][0] = false; $valid['name'][0] = false;
$valid['name'][1] = 'Webstream name cannot be empty'; $valid['name'][1] = _('Webstream name cannot be empty');
} }
$id = $parameters["id"]; $id = $parameters["id"];
@ -266,7 +266,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
} }
} }
throw new Exception("Could not parse XSPF playlist"); throw new Exception(_("Could not parse XSPF playlist"));
} }
private static function getPlsUrl($url) private static function getPlsUrl($url)
@ -278,7 +278,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
return $ini["playlist"]["File1"]; return $ini["playlist"]["File1"];
} }
throw new Exception("Could not parse PLS playlist"); throw new Exception(_("Could not parse PLS playlist"));
} }
private static function getM3uUrl($url) private static function getM3uUrl($url)
@ -297,7 +297,7 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
return $lines[0]; return $lines[0];
} }
throw new Exception("Could not parse M3U playlist"); throw new Exception(_("Could not parse M3U playlist"));
} }
private static function getMediaUrl($url, $mime, $content_length_found) private static function getMediaUrl($url, $mime, $content_length_found)
@ -311,11 +311,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable
$media_url = self::getPlsUrl($url); $media_url = self::getPlsUrl($url);
} elseif (preg_match("/(mpeg|ogg)/", $mime)) { } elseif (preg_match("/(mpeg|ogg)/", $mime)) {
if ($content_length_found) { if ($content_length_found) {
throw new Exception("Invalid webstream - This appears to be a file download."); throw new Exception(_("Invalid webstream - This appears to be a file download."));
} }
$media_url = $url; $media_url = $url;
} else { } else {
throw new Exception("Unrecognized stream type: $mime"); throw new Exception(sprintf(_("Unrecognized stream type: %s"), $mime));
} }
return $media_url; return $media_url;