From 8693cf61bb5df16212a19873b1232028df8d9ffe Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 8 Jul 2014 14:28:14 -0500 Subject: [PATCH] i18n: Simplify and consolidate error messages --- attachment.php | 4 +- include/ajax.content.php | 3 +- include/ajax.tickets.php | 2 +- include/ajax.users.php | 8 +-- include/class.api.php | 6 ++- include/class.canned.php | 5 +- include/class.category.php | 11 +++-- include/class.dept.php | 6 ++- include/class.email.php | 6 ++- include/class.faq.php | 5 +- include/class.filter.php | 6 ++- include/class.group.php | 10 ++-- include/class.page.php | 5 +- include/class.sla.php | 6 ++- include/class.staff.php | 6 ++- include/class.team.php | 6 ++- include/class.template.php | 8 +-- include/class.topic.php | 8 +-- include/staff/settings-tickets.inc.php | 4 +- kb/faq.php | 4 +- kb/file.php | 2 +- scp/apikeys.php | 44 ++++++++++------- scp/attachment.php | 2 +- scp/banlist.php | 39 +++++++++------ scp/canned.php | 43 ++++++++++------ scp/categories.php | 45 ++++++++++------- scp/departments.php | 58 +++++++++++++++------- scp/emails.php | 28 ++++++----- scp/faq.php | 31 ++++++------ scp/filters.php | 46 ++++++++++------- scp/forms.php | 18 ++++--- scp/groups.php | 46 ++++++++++------- scp/helptopics.php | 45 +++++++++++------ scp/lists.php | 33 ++++++++----- scp/logs.php | 12 +++-- scp/orgs.php | 17 ++++--- scp/pages.php | 49 ++++++++++++------- scp/plugins.php | 9 ++-- scp/profile.php | 2 +- scp/settings.php | 2 +- scp/slas.php | 50 ++++++++++++------- scp/staff.php | 47 +++++++++++------- scp/teams.php | 48 +++++++++++------- scp/templates.php | 68 +++++++++++++++++--------- scp/tickets.php | 38 ++++++++------ scp/users.php | 26 +++++----- 46 files changed, 610 insertions(+), 357 deletions(-) diff --git a/attachment.php b/attachment.php index 0b18dbf8d..05e256a42 100644 --- a/attachment.php +++ b/attachment.php @@ -22,14 +22,14 @@ if(!$thisclient || !$_GET['h'] || !($attachment=Attachment::lookup($_GET['id'])) || !($file=$attachment->getFile())) - die(__('Unknown or invalid attachment')); + Http::response(404, __('Unknown or invalid file')); //Validate session access hash - we want to make sure the link is FRESH! and the user has access to the parent ticket!! $vhash=md5($attachment->getFileId().session_id().strtolower($file->getKey())); if(strcasecmp(trim($_GET['h']),$vhash) || !($ticket=$attachment->getTicket()) || !$ticket->checkUserAccess($thisclient)) - die(__('Unknown or invalid attachment')); + Http::response(404, __('Unknown or invalid file')); //Download the file.. $file->download(); diff --git a/include/ajax.content.php b/include/ajax.content.php index 57ede7c6a..f283e2640 100644 --- a/include/ajax.content.php +++ b/include/ajax.content.php @@ -32,7 +32,8 @@ class ContentAjaxAPI extends AjaxController { __('IP Address'), $log->getIP()); }else { - $content='<div style="width:295px;"> <strong>'.__('Error').':</strong>'.__('Unknown or invalid log ID').'</div>'; + $content='<div style="width:295px;"> <strong>'.__('Error').':</strong>'. + sprintf(__('%s: Unknown or invalid ID.'), __('log entry')).'</div>'; } return $content; diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 817d46946..0c17f43aa 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -404,7 +404,7 @@ class TicketsAjaxAPI extends AjaxController { if($errors && $errors['err']) { $info +=array('error' => $errors['err']); } else { - $info +=array('error' =>__('Unable to add collaborator - try again')); + $info +=array('error' =>__('Unable to add collaborator. Internal error')); } return self::_addcollaborator($ticket, $user, $form, $info); diff --git a/include/ajax.users.php b/include/ajax.users.php index 06cf091ae..4f1c2b359 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -230,7 +230,7 @@ class UsersAjaxAPI extends AjaxController { if(($user=User::lookup(($id) ? $id : $_REQUEST['id']))) Http::response(201, $user->to_json()); - $info = array('error' => __('Unknown or invalid user')); + $info = array('error' => sprintf(__('%s: Unknown or invalid ID.'), _N('end user', 'end users', 1))); return self::_lookupform(null, $info); } @@ -370,13 +370,15 @@ class UsersAjaxAPI extends AjaxController { } else { //Creating new org. $form = OrganizationForm::getDefaultForm()->getForm($_POST); if (!($org = Organization::fromForm($form))) - $info['error'] = __('Unable to create organization - try again!'); + $info['error'] = __('Unable to create organization.') + .' '.__('Correct error(s) below and try again.'); } if ($org && $user->setOrganization($org)) Http::response(201, $org->to_json()); elseif (! $info['error']) - $info['error'] = __('Unable to add organization - try again!'); + $info['error'] = __('Unable to add user to organization.') + .' '.__('Correct error(s) below and try again.'); } elseif ($orgId) $org = Organization::lookup($orgId); diff --git a/include/class.api.php b/include/class.api.php index d7a2d02ef..4c78d5bbc 100644 --- a/include/class.api.php +++ b/include/class.api.php @@ -137,7 +137,8 @@ class API { if(db_query($sql)) return true; - $errors['err']=__('Unable to update API key. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this API key')) + .' '.__('Internal error occurred'); } else { $sql='INSERT INTO '.API_KEY_TABLE.' SET '.$sql @@ -148,7 +149,8 @@ class API { if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to add API key. Try again!'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this API key')); } return false; diff --git a/include/class.canned.php b/include/class.canned.php index 7ab5a357f..a7154b974 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -268,14 +268,15 @@ class Canned { if(db_query($sql)) return true; - $errors['err']=__('Unable to update canned response.'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this canned response')); } else { $sql='INSERT INTO '.CANNED_TABLE.' SET '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to create the canned response. Internal error'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this canned response')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.category.php b/include/class.category.php index 7a03642b0..5f67c6ee5 100644 --- a/include/class.category.php +++ b/include/class.category.php @@ -119,11 +119,11 @@ class Category { //Cleanup. $vars['name']=Format::striptags(trim($vars['name'])); - + //validate if($id && $id!=$vars['id']) - $errors['err']=__('Internal error. Try again'); - + $errors['err']=__('Internal error occurred'); + if(!$vars['name']) $errors['name']=__('Category name is required'); elseif(strlen($vars['name'])<3) @@ -151,14 +151,15 @@ class Category { if(db_query($sql)) return true; - $errors['err']=__('Unable to update FAQ category.'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this FAQ category')); } else { $sql='INSERT INTO '.FAQ_CATEGORY_TABLE.' SET '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to create FAQ category. Internal error'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this FAQ category')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.dept.php b/include/class.dept.php index 321e9c2ec..7abb372d1 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -448,7 +448,8 @@ class Dept { if(db_query($sql) && db_affected_rows()) return true; - $errors['err']=sprintf(__('Unable to update "%s" Department. Error occurred'),Format::htmlchars($vars['name'])); + $errors['err']=sprintf(__('Unable to update %s.'), __('this department')) + .' '.__('Internal error occurred'); } else { if (isset($vars['id'])) @@ -459,7 +460,8 @@ class Dept { return $id; - $errors['err']=__('Unable to create department. Internal error'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this department')) + .' '.__('Internal error occurred'); } diff --git a/include/class.email.php b/include/class.email.php index 8e489b4bb..40cabccd2 100644 --- a/include/class.email.php +++ b/include/class.email.php @@ -408,13 +408,15 @@ class Email { if(db_query($sql) && db_affected_rows()) return true; - $errors['err']=__('Unable to update email. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this email')) + .' '.__('Internal error occurred'); }else { $sql='INSERT INTO '.EMAIL_TABLE.' SET '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to add email. Internal error'); + $errors['err']=sprintf(__('Unable to add %s.'), __('this email')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.faq.php b/include/class.faq.php index 6cdaae015..1786c79f6 100644 --- a/include/class.faq.php +++ b/include/class.faq.php @@ -315,14 +315,15 @@ class FAQ { if(db_query($sql)) return true; - $errors['err']=__('Unable to update FAQ.'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this FAQ article')); } else { $sql='INSERT INTO '.FAQ_TABLE.' SET '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to create FAQ. Internal error'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this FAQ article')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.filter.php b/include/class.filter.php index 1b209bf70..010b27a72 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -532,11 +532,13 @@ class Filter { if($id) { $sql='UPDATE '.FILTER_TABLE.' SET '.$sql.' WHERE id='.db_input($id); if(!db_query($sql)) - $errors['err']=__('Unable to update the filter. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this ticket filter')) + .' '.__('Internal error occurred'); }else{ $sql='INSERT INTO '.FILTER_TABLE.' SET '.$sql.',created=NOW() '; if(!db_query($sql) || !($id=db_insert_id())) - $errors['err']=__('Unable to add filter. Internal error'); + $errors['err']=sprintf(__('Unable to add %s.'), __('this ticket filter')) + .' '.__('Internal error occurred'); } if($errors || !$id) return false; diff --git a/include/class.group.php b/include/class.group.php index 6d9d685b2..4187f21dc 100644 --- a/include/class.group.php +++ b/include/class.group.php @@ -218,14 +218,16 @@ class Group { if(($res=db_query($sql))) return true; - $errors['err']=__('Unable to update group. Internal error occurred.'); - + $errors['err']=sprintf(__('Unable to update %s.'), __('this group')) + .' '.__('Internal error occurred'); + }else{ $sql='INSERT INTO '.GROUP_TABLE.' '.$sql.',created=NOW()'; if(($res=db_query($sql)) && ($id=db_insert_id())) return $id; - - $errors['err']=__('Unable to create the group. Internal error'); + + $errors['err']=sprintf(__('Unable to create %s.'), __('this group')) + .' '.__('Internal error occurrred'); } return false; diff --git a/include/class.page.php b/include/class.page.php index ec74cf5a6..88d91d2cd 100644 --- a/include/class.page.php +++ b/include/class.page.php @@ -264,12 +264,13 @@ class Page { if(db_query($sql)) return true; - $errors['err']=__('Unable to update page.'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this site page')); } else { $sql='INSERT INTO '.PAGE_TABLE.' SET '.$sql.', created=NOW()'; if (!db_query($sql) || !($id=db_insert_id())) { - $errors['err']=__('Unable to create page. Internal error'); + $errors['err']=sprintf(_('Unable to create %s.'), __('this site page')) + .' '.__('Internal error occurred'); return false; } diff --git a/include/class.sla.php b/include/class.sla.php index 4b3455bc1..81e897cc7 100644 --- a/include/class.sla.php +++ b/include/class.sla.php @@ -187,7 +187,8 @@ class SLA { if(db_query($sql)) return true; - $errors['err']=__('Unable to update SLA. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this SLA plan')) + .' '.__('Internal error occurred'); }else{ if (isset($vars['id'])) $sql .= ', id='.db_input($vars['id']); @@ -196,7 +197,8 @@ class SLA { if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to add SLA. Internal error occurred'); + $errors['err']=sprintf(__('Unable to add %s.'), __('this SLA plan')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.staff.php b/include/class.staff.php index a7adf6878..836fa09de 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -811,13 +811,15 @@ class Staff extends AuthenticatedUser { if(db_query($sql) && db_affected_rows()) return true; - $errors['err']=__('Unable to update the user. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this agent')) + .' '.__('Internal error occurred'); } else { $sql='INSERT INTO '.STAFF_TABLE.' '.$sql.', created=NOW()'; if(db_query($sql) && ($uid=db_insert_id())) return $uid; - $errors['err']=__('Unable to create user. Internal error occurred'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this agent')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.team.php b/include/class.team.php index 3e5c02a9d..11670c853 100644 --- a/include/class.team.php +++ b/include/class.team.php @@ -252,13 +252,15 @@ class Team { if(db_query($sql) && db_affected_rows()) return true; - $errors['err']=__('Unable to update the team. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this team')) + .' '.__('Internal error occurred'); } else { $sql='INSERT INTO '.TEAM_TABLE.' '.$sql.',created=NOW()'; if(db_query($sql) && ($id=db_insert_id())) return $id; - $errors['err']=__('Unable to create the team. Internal error occurred'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this team')) + .' '.__('Internal error occurred'); } return false; diff --git a/include/class.template.php b/include/class.template.php index afdcf6039..c9d6711ed 100644 --- a/include/class.template.php +++ b/include/class.template.php @@ -317,7 +317,7 @@ class EmailTemplateGroup { $vars['name']=Format::striptags(trim($vars['name'])); if($id && $id!=$vars['tpl_id']) - $errors['err']=__('Internal error occurred. Try again'); + $errors['err']=__('Internal error occurred'); if(!$vars['name']) $errors['name']=__('Name is required'); @@ -343,7 +343,8 @@ class EmailTemplateGroup { if(db_query($sql)) return true; - $errors['err']=__('Unable to update the template. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this template set')) + .' '.__('Internal error occurred'); } else { @@ -352,7 +353,8 @@ class EmailTemplateGroup { $sql='INSERT INTO '.EMAIL_TEMPLATE_GRP_TABLE .' SET created=NOW(), '.$sql; if(!db_query($sql) || !($new_id=db_insert_id())) { - $errors['err']=__('Unable to create template. Internal error occurred'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this template set')) + .' '.__('Internal error occurred'); return false; } diff --git a/include/class.topic.php b/include/class.topic.php index 6a616d1c7..ecaeb53b9 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -304,7 +304,7 @@ class Topic { $vars['topic']=Format::striptags(trim($vars['topic'])); if($id && $id!=$vars['id']) - $errors['err']=__('Internal error occurred. Try again'); + $errors['err']=__('Internal error occurred'); if(!$vars['topic']) $errors['topic']=__('Help topic name is required'); @@ -347,7 +347,8 @@ class Topic { if ($id) { $sql='UPDATE '.TOPIC_TABLE.' SET '.$sql.' WHERE topic_id='.db_input($id); if (!($rv = db_query($sql))) - $errors['err']=__('Unable to update topic. Internal error occurred'); + $errors['err']=sprintf(__('Unable to update %s.'), __('this help topic')) + .' '.__('Internal error occurred'); } else { if (isset($vars['topic_id'])) $sql .= ', topic_id='.db_input($vars['topic_id']); @@ -363,7 +364,8 @@ class Topic { if (db_query($sql) && ($id = db_insert_id())) $rv = $id; else - $errors['err']=__('Unable to create the topic. Internal error occurred'); + $errors['err']=sprintf(__('Unable to create %s.'), __('this help topic')) + .' '.__('Internal error occurred'); } if (!$cfg || $cfg->getTopicSortMode() == 'a') { static::updateSortOrder(); diff --git a/include/staff/settings-tickets.inc.php b/include/staff/settings-tickets.inc.php index 9550425c3..aefe01771 100644 --- a/include/staff/settings-tickets.inc.php +++ b/include/staff/settings-tickets.inc.php @@ -189,7 +189,7 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) for($i = 1; $i <=$maxfileuploads; $i++) { ?> <option <?php echo $config['max_user_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> - <?php echo $i; ?> <?php echo ($i>1)?__('files'):__('file'); ?></option> + <?php echo sprintf(_N('%d file', '%d files', $i), $i); ?></option> <?php } ?> </select> @@ -205,7 +205,7 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) for($i = 1; $i <=$maxfileuploads; $i++) { ?> <option <?php echo $config['max_staff_file_uploads']==$i?'selected="selected"':''; ?> value="<?php echo $i; ?>"> - <?php echo $i; ?> <?php echo ($i>1)?__('files'):__('file'); ?></option> + <?php echo sprintf(_N('%d file', '%d files', $i), $i); ?></option> <?php } ?> </select> diff --git a/kb/faq.php b/kb/faq.php index 122bafc37..529535cd9 100644 --- a/kb/faq.php +++ b/kb/faq.php @@ -18,10 +18,10 @@ require_once(INCLUDE_DIR.'class.faq.php'); $faq=$category=null; if($_REQUEST['id'] && !($faq=FAQ::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid FAQ'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('FAQ article')); if(!$faq && $_REQUEST['cid'] && !($category=Category::lookup($_REQUEST['cid']))) - $errors['err']=__('Unknown or invalid FAQ category'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('FAQ category')); $inc='knowledgebase.inc.php'; //FAQs landing page. diff --git a/kb/file.php b/kb/file.php index bdd59b528..99664708a 100644 --- a/kb/file.php +++ b/kb/file.php @@ -24,7 +24,7 @@ $h=trim($_GET['h']); if(!$h || strlen($h)!=64 //32*2 || !($file=AttachmentFile::lookup(substr($h,0,32))) //first 32 is the file hash. || strcasecmp($h, $file->getDownloadHash())) //next 32 is file id + session hash. - die(__('Unknown or invalid attachment')); + Http::response(404, __('Unknown or invalid file')); $file->download(); ?> diff --git a/scp/apikeys.php b/scp/apikeys.php index 1b10a7452..c4de31810 100644 --- a/scp/apikeys.php +++ b/scp/apikeys.php @@ -18,30 +18,31 @@ include_once(INCLUDE_DIR.'class.api.php'); $api=null; if($_REQUEST['id'] && !($api=API::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid API key ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('API key')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$api){ - $errors['err']=__('Unknown or invalid API key.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('API key')); }elseif($api->update($_POST,$errors)){ - $msg=__('API key updated successfully'); + $msg=sprintf(__('Succesfully updated %s'), __('this API key')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating API key. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), __('this API key')); } break; case 'add': if(($id=API::add($_POST,$errors))){ - $msg=__('API key added successfully'); + $msg=sprintf(__('Successfully added %s'), __('an API key')); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add an API key. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this API key')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one API key'); + $errors['err'] = sprintf(__('You must select at least %s'), __('one API key')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -50,11 +51,14 @@ if($_POST){ .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected API keys enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected API key', 'selected API keys', $count)); else - $warn = sprintf(__('%1$d of %2$d selected API keys enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected API key', 'selected API keys', $count)); } else { - $errors['err'] = __('Unable to enable selected API keys.'); + $errors['err'] = sprintf(__('Unable to enable %s.'), + _N('selected API key', 'selected API keys', $count)); } break; case 'disable': @@ -62,11 +66,14 @@ if($_POST){ .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected API keys disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected API key', 'selected API keys', $count)); else - $warn = sprintf(__('%1$d of %2$d selected API keys disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected API key', 'selected API keys', $count)); } else { - $errors['err']=__('Unable to disable selected API keys'); + $errors['err']=sprintf(__('Unable to disable %s'), + _N('selected API key', 'selected API keys', $count)); } break; case 'delete': @@ -76,11 +83,14 @@ if($_POST){ $i++; } if($i && $i==$count) - $msg = __('Selected API keys deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected API key', 'selected API keys', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected API keys deleted'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $num, $count, + _N('selected API key', 'selected API keys', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected API keys'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected API key', 'selected API keys', $count)); break; default: $errors['err']=__('Unknown action - get technical help.'); @@ -88,7 +98,7 @@ if($_POST){ } break; default: - $errors['err']=__('Unknown action/command'); + $errors['err']=__('Unknown action'); break; } } diff --git a/scp/attachment.php b/scp/attachment.php index 113316002..07f20981a 100644 --- a/scp/attachment.php +++ b/scp/attachment.php @@ -20,7 +20,7 @@ require_once(INCLUDE_DIR.'class.attachment.php'); if(!$thisstaff || !$_GET['id'] || !$_GET['h'] || !($attachment=Attachment::lookup($_GET['id'])) || !($file=$attachment->getFile())) - Http::response(404, __('Unknown or invalid attachment')); + Http::response(404, __('Unknown or invalid file')); //Validate session access hash - we want to make sure the link is FRESH! and the user has access to the parent ticket!! $vhash=md5($attachment->getFileId().session_id().strtolower($file->getKey())); diff --git a/scp/banlist.php b/scp/banlist.php index 211572128..57c84f4f7 100644 --- a/scp/banlist.php +++ b/scp/banlist.php @@ -26,13 +26,13 @@ elseif(!$filter->isActive()) $rule=null; //ban rule obj. if($filter && $_REQUEST['id'] && !($rule=$filter->getRule($_REQUEST['id']))) - $errors['err'] = __('Unknown or invalid ban list ID #'); + $errors['err'] = sprintf(__('%s: Unknown or invalid ID.'), __('ban list')); if($_POST && !$errors && $filter){ switch(strtolower($_POST['do'])){ case 'update': if(!$rule){ - $errors['err']=__('Unknown or invalid ban rule.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ban rule')); }elseif(!$_POST['val'] || !Validator::is_email($_POST['val'])){ $errors['err']=$errors['val']=__('Valid email address required'); }elseif(!$errors){ @@ -43,15 +43,15 @@ if($_POST && !$errors && $filter){ 'isactive'=>$_POST['isactive'], 'notes'=>$_POST['notes']); if($rule->update($vars,$errors)){ - $msg=__('Email updated successfully'); + $msg=sprintf(__('Successfully updated %s'), Format::htmlchars($_POST['val'])); }elseif(!$errors['err']){ - $errors['err']=__('Error updating ban rule. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), __('this ban rule')); } } break; case 'add': if(!$filter) { - $errors['err']=__('Unknown or invalid ban list'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ban list')); }elseif(!$_POST['val'] || !Validator::is_email($_POST['val'])) { $errors['err']=$errors['val']=__('Valid email address required'); }elseif(BanList::includes(trim($_POST['val']))) { @@ -61,7 +61,7 @@ if($_POST && !$errors && $filter){ $_REQUEST['a']=null; //Add filter rule here. }elseif(!$errors['err']){ - $errors['err']=__('Error creating ban rule. Try again!'); + $errors['err']=sprintf(__('Error creating %s. Try again!'), __('ban rule')); } break; case 'mass_process': @@ -76,11 +76,14 @@ if($_POST && !$errors && $filter){ .' AND id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())){ if($num==$count) - $msg = __('Selected emails ban status set to enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected ban rule', 'selected ban rules', $count)); else - $warn = sprintf(__('%1$d of %2$d selected emails ban status enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected ban rule', 'selected ban rules', $count)); } else { - $errors['err'] = __('Unable to enable selected emails'); + $errors['err'] = sprintf(__('Unable to enable %s'), + _N('selected ban rule', 'selected ban rules', $count)); } break; case 'disable': @@ -89,11 +92,14 @@ if($_POST && !$errors && $filter){ .' AND id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected emails ban status set to disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected ban rule', 'selected ban rules', $count)); else - $warn = sprintf(__('%1$d of %2$d selected emails ban status set to disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected ban rule', 'selected ban rules', $count)); } else { - $errors['err'] = __('Unable to disable selected emails'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected ban rule', 'selected ban rules', $count)); } break; case 'delete': @@ -103,11 +109,14 @@ if($_POST && !$errors && $filter){ $i++; } if($i && $i==$count) - $msg = __('Selected emails deleted from banlist successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected ban rule', 'selected ban rules', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected emails deleted from banlist'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected ban rule', 'selected ban rules', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected emails'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected ban rule', 'selected ban rules', $count)); break; default: diff --git a/scp/canned.php b/scp/canned.php index d71b94f98..b9a1ea3c3 100644 --- a/scp/canned.php +++ b/scp/canned.php @@ -26,15 +26,16 @@ if(!$thisstaff || !$thisstaff->canManageCannedResponses()) { $canned=null; if($_REQUEST['id'] && !($canned=Canned::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid canned response ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('canned response')); if($_POST && $thisstaff->canManageCannedResponses()) { switch(strtolower($_POST['do'])) { case 'update': if(!$canned) { - $errors['err']=__('Unknown or invalid canned response.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('canned response')); } elseif($canned->update($_POST, $errors)) { - $msg=__('Canned response updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this canned response')); //Delete removed attachments. //XXX: files[] shouldn't be changed under any circumstances. $keepers = $_POST['files']?$_POST['files']:array(); @@ -68,12 +69,12 @@ if($_POST && $thisstaff->canManageCannedResponses()) { // Delete drafts for all users for this canned response Draft::deleteForNamespace('canned.'.$canned->getId()); } elseif(!$errors['err']) { - $errors['err']=__('Error updating canned response. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), __('this canned response')); } break; case 'create': if(($id=Canned::create($_POST, $errors))) { - $msg=__('Canned response added successfully'); + $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['title'])); $_REQUEST['a']=null; //Upload attachments if($_FILES['attachments'] && ($c=Canned::lookup($id)) && ($files=AttachmentFile::format($_FILES['attachments']))) @@ -88,12 +89,13 @@ if($_POST && $thisstaff->canManageCannedResponses()) { // Delete this user's drafts for new canned-responses Draft::deleteForNamespace('canned', $thisstaff->getId()); } elseif(!$errors['err']) { - $errors['err']=__('Unable to add canned response. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this canned response')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err']=__('You must select at least one canned response'); + $errors['err']=sprintf(__('You must select at least %s'), __('one canned response')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -102,11 +104,14 @@ if($_POST && $thisstaff->canManageCannedResponses()) { .' WHERE canned_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected canned responses enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected canned response', 'selected canned responses', $count)); else - $warn = sprintf(__('%1$d of %2$d selected canned responses enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %s enabled'), $num, $count, + _N('selected canned response', 'selected canned responses', $count)); } else { - $errors['err'] = __('Unable to enable selected canned responses.'); + $errors['err'] = sprintf(__('Unable to enable %s.'), + _N('selected canned response', 'selected canned responses', $count)); } break; case 'disable': @@ -114,11 +119,14 @@ if($_POST && $thisstaff->canManageCannedResponses()) { .' WHERE canned_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected canned responses disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected canned response', 'selected canned responses', $count)); else - $warn = sprintf(__('%1$d of %2$d selected canned responses disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %s disabled'), $num, $count, + _N('selected canned response', 'selected canned responses', $count)); } else { - $errors['err'] = __('Unable to disable selected canned responses'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected canned response', 'selected canned responses', $count)); } break; case 'delete': @@ -130,11 +138,14 @@ if($_POST && $thisstaff->canManageCannedResponses()) { } if($i==$count) - $msg = __('Selected canned responses deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected canned response', 'selected canned responses', $count)); elseif($i>0) - $warn=sprintf(__('%1$d of %2$d selected canned responses deleted'), $i, $count); + $warn=sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected canned response', 'selected canned responses', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected canned responses'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected canned response', 'selected canned responses', $count)); break; default: $errors['err']=__('Unknown command'); diff --git a/scp/categories.php b/scp/categories.php index 3d6f55ec7..8afdc4c0f 100644 --- a/scp/categories.php +++ b/scp/categories.php @@ -25,30 +25,32 @@ if(!$thisstaff || !$thisstaff->canManageFAQ()) { $category=null; if($_REQUEST['id'] && !($category=Category::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid category ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('category')); if($_POST){ switch(strtolower($_POST['do'])) { case 'update': if(!$category) { - $errors['err']=__('Unknown or invalid category.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('category')); } elseif($category->update($_POST,$errors)) { - $msg=__('Category updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this category')); } elseif(!$errors['err']) { - $errors['err']=__('Error updating category. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Correct error(s) below and try again.'), __('this category')); } break; case 'create': if(($id=Category::create($_POST,$errors))) { - $msg=__('Category added successfully'); + $msg=sprintf(__('Successfull added %s'), Format::htmlchars($_POST['name'])); $_REQUEST['a']=null; } elseif(!$errors['err']) { - $errors['err']=__('Unable to add category. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this category')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err']=__('You must select at least one category'); + $errors['err']=sprintf(__('You must select at least %s'), __('one category')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -58,11 +60,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected categories made PUBLIC'); + $msg = sprintf(__('Successfully made %s PUBLIC'), + _N('selected category', 'selected categories', $count)); else - $warn = sprintf(__('%1$d of %2$d selected categories made PUBLIC'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s made PUBLIC'), $num, $count, + _N('selected category', 'selected categories', $count)); } else { - $errors['err'] = __('Unable to enable selected categories public.'); + $errors['err'] = sprintf(__('Unable to make %s PUBLIC.'), + _N('selected category', 'selected categories', $count)); } break; case 'make_private': @@ -71,11 +76,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected categories made PRIVATE'); + $msg = sprintf(__('Successfully made %s PRIVATE'), + _N('selected category', 'selected categories', $count)); else - $warn = sprintf(__('%1$d of %2$d selected categories made PRIVATE'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s made PRIVATE'), $num, $count, + _N('selected category', 'selected categories', $count)); } else { - $errors['err'] = __('Unable to disable selected categories PRIVATE'); + $errors['err'] = sprintf(__('Unable to make %s PRIVATE'), + _N('selected category', 'selected categories', $count)); } break; case 'delete': @@ -86,14 +94,17 @@ if($_POST){ } if($i==$count) - $msg = __('Selected categories deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected category', 'selected categories', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected categories deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected category', 'selected categories', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected categories'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected category', 'selected categories', $count)); break; default: - $errors['err']=__('Unknown action/command'); + $errors['err']=__('Unknown action - get technical help.'); } } break; diff --git a/scp/departments.php b/scp/departments.php index ef9d4a110..999380219 100644 --- a/scp/departments.php +++ b/scp/departments.php @@ -17,32 +17,36 @@ require('admin.inc.php'); $dept=null; if($_REQUEST['id'] && !($dept=Dept::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid department ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('department')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$dept){ - $errors['err']=__('Unknown or invalid department.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('department')); }elseif($dept->update($_POST,$errors)){ - $msg=__('Department updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this department')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating department. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this department')); } break; case 'create': if(($id=Dept::create($_POST,$errors))){ - $msg=sprintf(__('%s added successfully'),Format::htmlchars($_POST['name'])); + $msg=sprintf(__('Successfully added "%s"'),Format::htmlchars($_POST['name'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add department. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this department')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one department'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one department')); }elseif(in_array($cfg->getDefaultDeptId(),$_POST['ids'])) { - $errors['err'] = __('You can not disable/delete a default department. Select a new default department and try again.'); + $errors['err'] = __('You cannot disable/delete a default department. Select a new default department and try again.'); }else{ $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -51,11 +55,17 @@ if($_POST){ .' WHERE dept_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())){ if($num==$count) - $msg=__('Selected departments made public'); + $msg=sprintf(__('Successfully made %s PUBLIC'), + _N('selected department', 'selected departments', $count)); else - $warn=sprintf(__('%1$d of %2$d selected departments made public'), $num, $count); + $warn=sprintf(__( + /* Phrase will read: + <a> of <b> <selected objects> made PUBLIC */ + '%1$d of %2$d %s made PUBLIC'), $num, $count, + _N('selected department', 'selected departments', $count)); } else { - $errors['err']=__('Unable to make selected department public.'); + $errors['err']=sprintf(__('Unable to make %s PUBLIC.'), + _N('selected department', 'selected departments', $count)); } break; case 'make_private': @@ -64,11 +74,17 @@ if($_POST){ .' AND dept_id!='.db_input($cfg->getDefaultDeptId()); if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected departments made private'); + $msg = sprintf(__('Successfully made %s PRIVATE'), + _N('selected department', 'selected epartments', $count)); else - $warn = sprintf(__('%1$d of %2$d selected departments made private'), $num, $count); + $warn = sprintf(__( + /* Phrase will read: + <a> of <b> <selected objects> made PRIVATE */ + '%1$d of %2$d %3$s made PRIVATE'), $num, $count, + _N('selected department', 'selected departments', $count)); } else { - $errors['err'] = __('Unable to make selected department(s) private. Possibly already private!'); + $errors['err'] = sprintf(__('Unable to make %s private. Possibly already private!'), + _N('selected department', 'selected departments', $count)); } break; case 'delete': @@ -85,11 +101,17 @@ if($_POST){ $i++; } if($i && $i==$count) - $msg = __('Selected departments deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected department', 'selected departments', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected departments deleted'), $i, $count); + $warn = sprintf(__( + /* Phrase will read: + <a> of <b> <selected objects> deleted */ + '%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected department', 'selected departments', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected departments.'); + $errors['err'] = sprintf(__('Unable to delete %s.'), + _N('selected department', 'selected departments', $count)); } break; default: @@ -98,7 +120,7 @@ if($_POST){ } break; default: - $errors['err']=__('Unknown action/command'); + $errors['err']=__('Unknown action'); break; } } diff --git a/scp/emails.php b/scp/emails.php index ad3bcf571..4e8bf4bef 100644 --- a/scp/emails.php +++ b/scp/emails.php @@ -18,30 +18,33 @@ include_once(INCLUDE_DIR.'class.email.php'); $email=null; if($_REQUEST['id'] && !($email=Email::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid email ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('email')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$email){ - $errors['err']=__('Unknown or invalid email.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('email')); }elseif($email->update($_POST,$errors)){ - $msg=__('Email updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this email')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating email. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), __('this email')); } break; case 'create': if(($id=Email::create($_POST,$errors))){ - $msg=__('Email address added successfully'); + $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['name'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add email. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this email')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one email address'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one email')); } else { $count=count($_POST['ids']); @@ -60,11 +63,14 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected emails deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected email', 'selected emails', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected emails deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected email', 'selected emails', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected emails'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected email', 'selected emails', $count)); } else { $errors['err'] = __('Unknown action - get technical help.'); @@ -72,7 +78,7 @@ if($_POST){ } break; default: - $errors['err'] = __('Unknown action/command'); + $errors['err'] = __('Unknown action'); break; } } diff --git a/scp/faq.php b/scp/faq.php index a2a26c4e7..47c61203d 100644 --- a/scp/faq.php +++ b/scp/faq.php @@ -18,10 +18,10 @@ require_once(INCLUDE_DIR.'class.faq.php'); $faq=$category=null; if($_REQUEST['id'] && !($faq=FAQ::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid FAQ'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('FAQ article')); if($_REQUEST['cid'] && !$faq && !($category=Category::lookup($_REQUEST['cid']))) - $errors['err']=__('Unknown or invalid FAQ category'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('FAQ category')); if($_POST): $errors=array(); @@ -29,28 +29,30 @@ if($_POST): case 'create': case 'add': if(($faq=FAQ::add($_POST,$errors))) { - $msg=__('FAQ added successfully'); + $msg=sprintf(__('Successfully added %s'), Format::htmlchars($faq->getQuestion())); // Delete draft for this new faq Draft::deleteForNamespace('faq', $thisstaff->getId()); } elseif(!$errors['err']) - $errors['err'] = __('Unable to add FAQ. Try again!'); + $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this FAQ article')); break; case 'update': case 'edit'; if(!$faq) - $errors['err'] = __('Invalid or unknown FAQ'); + $errors['err'] = sprintf(__('%s: Invalid or unknown'), __('FAQ article')); elseif($faq->update($_POST,$errors)) { - $msg=__('FAQ updated successfully'); + $msg=sprintf(__('Successfully updated %s'), __('this FAQ article')); $_REQUEST['a']=null; //Go back to view $faq->reload(); // Delete pending draft updates for this faq (for ALL users) Draft::deleteForNamespace('faq.'.$faq->getId()); } elseif(!$errors['err']) - $errors['err'] = __('Unable to update FAQ. Try again!'); + $errors['err'] = sprintf(__('Unable to update %s. Correct error(s) below and try again.'), + __('this FAQ article')); break; case 'manage-faq': if(!$faq) { - $errors['err']=__('Unknown or invalid FAQ'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('FAQ article')); } else { switch(strtolower($_POST['a'])) { case 'edit': @@ -58,23 +60,24 @@ if($_POST): break; case 'publish'; if($faq->publish()) - $msg=__('FAQ published successfully'); + $msg=sprintf(__('Successfully published %s'), __('this FAQ article')); else - $errors['err']=__('Unable to publish the FAQ. Try editing it.'); + $errors['err']=sprintf(__('Unable to publish %s. Try editing it.'), + __('this FAQ article')); break; case 'unpublish'; if($faq->unpublish()) - $msg=__('FAQ unpublished successfully'); + $msg=sprintf(__('Successfully unpublished %s'), __('this FAQ article')); else - $errors['err']=__('Unable to unpublish the FAQ. Try editing it.'); + $errors['err']=sprintf(__('Unable to unpublish %s. Try editing it.'), __('this FAQ article')); break; case 'delete': $category = $faq->getCategory(); if($faq->delete()) { - $msg=__('FAQ deleted successfully'); + $msg=sprintf(__('Successfully deleted %s'), Format::htmlchars($faq->getQuestion())); $faq=null; } else { - $errors['err']=__('Unable to delete FAQ. Try again'); + $errors['err']=sprintf(__('Unable to delete %s.'), __('this FAQ article')); } break; default: diff --git a/scp/filters.php b/scp/filters.php index 0521be3be..57b05e526 100644 --- a/scp/filters.php +++ b/scp/filters.php @@ -19,34 +19,37 @@ require_once(INCLUDE_DIR.'class.canned.php'); $filter=null; if($_REQUEST['id'] && !($filter=Filter::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid filter.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ticket filter')); /* NOTE: Banlist has its own interface*/ if($filter && $filter->isSystemBanlist()) - header('Location: banlist.php'); + Http::redirect('banlist.php'); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$filter){ - $errors['err']=__('Unknown or invalid filter.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('ticket filter')); }elseif($filter->update($_POST,$errors)){ - $msg=__('Filter updated successfully'); + $msg=sprintf(__('Successfully updated %s'), __('this ticket filter')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating filter. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Correct error(s) below and try again.'), + __('this ticket filter')); } break; case 'add': if((Filter::create($_POST,$errors))){ - $msg=__('Filter added successfully'); + $msg=sprintf(__('Successfully updated %s'), __('this ticket filter')); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add filter. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this ticket filter')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one filter to process.'); + $errors['err'] = sprintf(__('You must select at least %s to process.'), + __('one ticket filter')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -55,11 +58,14 @@ if($_POST){ .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected filters enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); else - $warn = sprintf(__('%1$d of %2$d selected filters enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected ticket filter', 'selected ticket filters', $count)); } else { - $errors['err'] = __('Unable to enable selected filters'); + $errors['err'] = sprintf(__('Unable to enable %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); } break; case 'disable': @@ -67,11 +73,14 @@ if($_POST){ .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected filters disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); else - $warn = sprintf(__('%1$d of %2$d selected filters disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected ticket filter', 'selected ticket filters', $count)); } else { - $errors['err'] = __('Unable to disable selected filters'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); } break; case 'delete': @@ -82,11 +91,14 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected filters deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected filters deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %s deleted'), $i, $count, + _N('selected ticket filter', 'selected ticket filters', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected filters'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected ticket filter', 'selected ticket filters', $count)); break; default: $errors['err']=__('Unknown action - get technical help.'); diff --git a/scp/forms.php b/scp/forms.php index cb5bdf322..dae8ecaf7 100644 --- a/scp/forms.php +++ b/scp/forms.php @@ -4,7 +4,7 @@ require_once(INCLUDE_DIR."/class.dynamic_forms.php"); $form=null; if($_REQUEST['id'] && !($form=DynamicForm::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid dynamic form ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('custom form')); if($_POST) { $fields = array('title', 'notes', 'instructions'); @@ -81,7 +81,7 @@ if($_POST) { case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one form'); + $errors['err'] = sprintf(__('You must select at least %s'), __('one custom form')); } else { $count = count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -92,11 +92,14 @@ if($_POST) { $i++; } if ($i && $i==$count) - $msg = __('Selected custom forms deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected custom form', 'selected custom forms', $count)); elseif ($i > 0) - $warn = sprintf(__('%1$d of %1$d selected forms deleted'), $i, $count); + $warn = sprintf(__('%1$d of %1$d %3$s deleted'), $i, $count, + _N('selected custom form', 'selected custom forms', $count)); elseif (!$errors['err']) - $errors['err'] = __('Unable to delete selected custom forms'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected custom form', 'selected custom forms', $count)); break; } } @@ -134,9 +137,10 @@ if($_POST) { } } if ($errors) - $errors['err'] = __('Unable to commit form. Check validation errors'); + $errors['err'] = sprintf(__('Unable to commit %s. Check validation errors'), __('this custom form')); else - $msg = __('Custom form successfully updated'); + $msg = sprintf(__('Successfully updated %s'), + __('this custom form')); } $page='dynamic-forms.inc.php'; diff --git a/scp/groups.php b/scp/groups.php index e0d2d06f0..c3f17f9c2 100644 --- a/scp/groups.php +++ b/scp/groups.php @@ -17,30 +17,33 @@ require('admin.inc.php'); $group=null; if($_REQUEST['id'] && !($group=Group::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid group ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('group')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$group){ - $errors['err']=__('Unknown or invalid group.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('group')); }elseif($group->update($_POST,$errors)){ - $msg=__('Group updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this group')); }elseif(!$errors['err']){ - $errors['err']=__('Unable to update group. Correct any error(s) below and try again!'); + $errors['err']=sprintf(__('Unable to update %s. Correct error(s) below and try again!'), + __('this group')); } break; case 'create': if(($id=Group::create($_POST,$errors))){ - $msg=sprintf(__('%s added successfully'),Format::htmlchars($_POST['name'])); + $msg=sprintf(__('Successfully added %s'),Format::htmlchars($_POST['name'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add group. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this group')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one group.'); + $errors['err'] = sprintf(__('You must select at least %s.'), __('one group')); } elseif(in_array($thisstaff->getGroupId(), $_POST['ids'])) { $errors['err'] = __("As an admin, you cannot disable/delete a group you belong to - you might lockout all admins!"); } else { @@ -52,11 +55,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())){ if($num==$count) - $msg = __('Selected groups activated'); + $msg = sprintf(__('Successfully activated %s'), + _N('selected group', 'selected groups', $count)); else - $warn = sprintf(__('%1$d of %2$d selected groups activated'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s activated'), $num, $count, + _N('selected group', 'selected groups', $count)); } else { - $errors['err'] = __('Unable to activate selected groups'); + $errors['err'] = sprintf(__('Unable to activate %s'), + _N('selected group', 'selected groups', $count)); } break; case 'disable': @@ -64,11 +70,14 @@ if($_POST){ .' WHERE group_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected groups disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected group', 'selected groups', $count)); else - $warn = sprintf(__('%1$d of %2$d selected groups disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected group', 'selected groups', $count)); } else { - $errors['err'] = __('Unable to disable selected groups'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected group', 'selected groups', $count)); } break; case 'delete': @@ -78,14 +87,17 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected groups deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected group', 'selected groups', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected groups deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected group', 'selected groups', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected groups'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected group', 'selected groups', $count)); break; default: - $errors['err'] = __('Unknown action. Get technical help!'); + $errors['err'] = __('Unknown action - get technical help.'); } } break; diff --git a/scp/helptopics.php b/scp/helptopics.php index d838d6124..44af9f9c9 100644 --- a/scp/helptopics.php +++ b/scp/helptopics.php @@ -19,25 +19,28 @@ require_once(INCLUDE_DIR.'class.dynamic_forms.php'); $topic=null; if($_REQUEST['id'] && !($topic=Topic::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid help topic ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('help topic')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$topic){ - $errors['err']=__('Unknown or invalid help topic.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('help topic')); }elseif($topic->update($_POST,$errors)){ - $msg=__('Help topic updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this help topic')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating help topic. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this help topic')); } break; case 'create': if(($id=Topic::create($_POST,$errors))){ - $msg=__('Help topic added successfully'); + $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['topic'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add help topic. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this help topic')); } break; case 'mass_process': @@ -47,7 +50,8 @@ if($_POST){ break; default: if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) - $errors['err'] = __('You must select at least one help topic'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one help topic')); } if (!$errors) { $count=count($_POST['ids']); @@ -59,11 +63,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected help topics enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected help topic', 'selected help topics', $count)); else - $warn = sprintf(__('%1$d of %2$d selected help topics enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected help topic', 'selected help topics', $count)); } else { - $errors['err'] = __('Unable to enable selected help topics.'); + $errors['err'] = sprintf(__('Unable to enable %s.'), + _N('selected help topic', 'selected help topics', $count)); } break; case 'disable': @@ -72,11 +79,14 @@ if($_POST){ .' AND topic_id <> '.db_input($cfg->getDefaultTopicId()); if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected help topics disabled'); + $msg = sprintf(__('Successfully diabled %s'), + _N('selected help topic', 'selected help topics', $count)); else - $warn = sprintf(__('%1$d of %2$d selected help topics disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected help topic', 'selected help topics', $count)); } else { - $errors['err'] =__('Unable to disable selected help topic(s)'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected help topic', 'selected help topics', $count)); } break; case 'delete': @@ -87,11 +97,14 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected help topics deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected help topic', 'selected elp topics', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected help topics deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected help topic', 'selected help topics', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected help topics'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected help topic', 'selected help topics', $count)); break; case 'sort': diff --git a/scp/lists.php b/scp/lists.php index 36c5d7b9b..84ae65787 100644 --- a/scp/lists.php +++ b/scp/lists.php @@ -4,7 +4,8 @@ require_once(INCLUDE_DIR."/class.dynamic_forms.php"); $list=null; if($_REQUEST['id'] && !($list=DynamicList::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid dynamic list ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), + __('custom list')); if ($list) $form = $list->getForm(); @@ -21,11 +22,14 @@ if($_POST) { elseif (isset($_POST[$f])) $list->set($f, $_POST[$f]); if ($errors) - $errors['err'] = __('Unable to update custom list. Correct any error(s) below and try again.'); + $errors['err'] = sprintf(__('Unable to update %s. Correct any error(s) below and try again.'), + __('this custom list')); elseif ($list->save(true)) - $msg = __('Custom list updated successfully'); + $msg = sprintf(__('Successfully updated %s'), + __('this custom list')); else - $errors['err'] = __('Unable to update custom list. Unknown internal error'); + $errors['err'] = sprintf(__('Unable to update %s.'), __('this custom list')) + .' '.__('Internal error occurred'); foreach ($list->getAllItems() as $item) { $id = $item->get('id'); @@ -101,20 +105,24 @@ if($_POST) { )); if ($errors) - $errors['err'] = __('Unable to create custom list. Correct any error(s) below and try again.'); + $errors['err'] = sprintf(__('Unable to create %s. Correct any error(s) below and try again.'), + __('this custom list')); elseif (!$list->save(true)) - $errors['err'] = __('Unable to create custom list: Unknown internal error'); + $errors['err'] = sprintf(__('Unable to create %s: Unknown internal error'), + __('this custom list')); $form->set('type', 'L'.$list->get('id')); if (!$errors && !$form->save(true)) $errors['err'] = __('Unable to create properties for custom list: Unknown internal error'); else - $msg = __('Custom list added successfully'); + $msg = sprintf(__('Successfully added %s'), + __('this custom list')); break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one custom list'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one custom list')); } else { $count = count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -125,11 +133,14 @@ if($_POST) { $i++; } if ($i && $i==$count) - $msg = __('Selected custom lists deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected custom list', 'selected custom lists', $count)); elseif ($i > 0) - $warn = sprintf(__('%1$d or %2$d selected lists deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected custom list', 'selected custom lists', $count)); elseif (!$errors['err']) - $errors['err'] = __('Unable to delete selected custom lists — they may be in use on a custom form'); + $errors['err'] = sprintf(__('Unable to delete %s — they may be in use on a custom form'), + _N('selected custom list', 'selected custom lists', $count)); break; } } diff --git a/scp/logs.php b/scp/logs.php index 2205e6950..df1779668 100644 --- a/scp/logs.php +++ b/scp/logs.php @@ -19,7 +19,8 @@ if($_POST){ switch(strtolower($_POST['do'])){ case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one log to delete'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one log entry')); } else { $count=count($_POST['ids']); if($_POST['a'] && !strcasecmp($_POST['a'], 'delete')) { @@ -28,11 +29,14 @@ if($_POST){ .' WHERE log_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())){ if($num==$count) - $msg=__('Selected logs deleted successfully'); + $msg=sprintf(__('Successfully deleted %s'), + _N('selected log entry', 'selected log entries', $count)); else - $warn=sprintf(__('%1$d of %2$d selected logs deleted'), $num, $count); + $warn=sprintf(__('%1$d of %2$d %3$s deleted'), $num, $count, + _N('selected log entry', 'selected log entries', $count)); } elseif(!$errors['err']) - $errors['err']=__('Unable to delete selected logs'); + $errors['err']=sprintf(__('Unable to delete %s'), + _N('selected log entry', 'selected log entries', $count)); } else { $errors['err']=__('Unknown action - get technical help.'); } diff --git a/scp/orgs.php b/scp/orgs.php index 6ffdf3575..22cd2aeca 100644 --- a/scp/orgs.php +++ b/scp/orgs.php @@ -29,15 +29,17 @@ if ($_POST) { $status = User::importFromPost($_FILES['import'] ?: $_POST['pasted'], array('org_id'=>$org->getId())); if (is_numeric($status)) - $msg = sprintf(__("Successfully imported %d clients"), $status); + $msg = sprintf(__('Successfully imported %1$d %2$s'), $status, + _N('end user', 'end users', $status)); else $errors['err'] = $status; break; case 'remove-users': if (!$org) - $errors['err'] = __('Trying to remove users from unknown organization'); + $errors['err'] = __('Trying to remove end users from an unknown organization'); elseif (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one user to remove'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one end user')); } else { $i = 0; foreach ($_POST['ids'] as $k=>$v) { @@ -46,11 +48,14 @@ if ($_POST) { } $num = count($_POST['ids']); if ($i && $i == $num) - $msg = __('Selected users removed successfully'); + $msg = sprintf(__('Successfully removed %s'), + _N('selected end user', 'selected end users', $count)); elseif ($i > 0) - $warn = sprintf(__('%1$d of %2$d selected users removed'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s removed'), $i, $count, + _N('selected end user', 'selected end users', $count)); elseif (!$errors['err']) - $errors['err'] = __('Unable to remove selected users'); + $errors['err'] = sprintf(__('Unable to remove %s'), + _N('selected end user', 'selected end users', $count)); } break; default: diff --git a/scp/pages.php b/scp/pages.php index c63072db0..dde430996 100644 --- a/scp/pages.php +++ b/scp/pages.php @@ -18,14 +18,14 @@ require_once(INCLUDE_DIR.'class.page.php'); $page = null; if($_REQUEST['id'] && !($page=Page::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid page'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('site page')); if($_POST) { switch(strtolower($_POST['do'])) { case 'add': if(($pageId=Page::create($_POST, $errors))) { $_REQUEST['a'] = null; - $msg=__('Page added successfully'); + $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['name'])); // Attach inline attachments from the editor if (isset($_POST['draft_id']) && ($draft = Draft::lookup($_POST['draft_id'])) @@ -34,13 +34,16 @@ if($_POST) { $draft->getAttachmentIds($_POST['response']), true); Draft::deleteForNamespace('page'); } elseif(!$errors['err']) - $errors['err'] = __('Unable to add page. Try again!'); + $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this site page')); break; case 'update': if(!$page) - $errors['err'] = __('Invalid or unknown page'); + $errors['err'] = sprintf(__('%s: Invalid or unknown'), + __('site page')); elseif($page->update($_POST, $errors)) { - $msg=__('Page updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this site page')); $_REQUEST['a']=null; //Go back to view // Attach inline attachments from the editor if (isset($_POST['draft_id']) @@ -52,13 +55,16 @@ if($_POST) { } Draft::deleteForNamespace('page.'.$page->getId()); } elseif(!$errors['err']) - $errors['err'] = __('Unable to update page. Try again!'); + $errors['err'] = sprintf(__('Unable to update %s. Correct error(s) below and try again.'), + __('this site page')); break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one page.'); + $errors['err'] = sprintf(__('You must select at least %s.'), + __('one site page')); } elseif(array_intersect($_POST['ids'], $cfg->getDefaultPages()) && strcasecmp($_POST['a'], 'enable')) { - $errors['err'] = __('One or more of the selected pages is in-use and CANNOT be disabled/deleted.'); + $errors['err'] = sprintf(__('One or more of the %s is in-use and CANNOT be disabled/deleted.'), + _N('selected site page', 'selected site pages', 2)); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -67,11 +73,14 @@ if($_POST) { .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected pages enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected site page', 'selected site pages', $count)); else - $warn = sprintf(__('%1$d of %2$d selected pages enabled'), $num, $count);; + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected site page', 'selected site pages', $count)); } else { - $errors['err'] = __('Unable to enable selected pages'); + $errors['err'] = sprintf(__('Unable to enable %s'), + _N('selected site page', 'selected site pages', $count)); } break; case 'disable': @@ -82,11 +91,14 @@ if($_POST) { } if($i && $i==$count) - $msg = __('Selected pages disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected site page', 'selected site pages', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected pages disabled'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $i, $count, + _N('selected site page', 'selected site pages', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to disable selected pages'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected site page', 'selected site pages', $count)); break; case 'delete': $i=0; @@ -96,11 +108,14 @@ if($_POST) { } if($i && $i==$count) - $msg = __('Selected pages deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected site page', 'selected site pages', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected pages deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected site page', 'selected site pages', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected pages'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected site page', 'selected site pages', $count)); break; default: $errors['err']=__('Unknown action - get technical help.'); diff --git a/scp/plugins.php b/scp/plugins.php index ee8e8bf87..ccc856e3a 100644 --- a/scp/plugins.php +++ b/scp/plugins.php @@ -3,7 +3,8 @@ require('admin.inc.php'); require_once(INCLUDE_DIR."/class.plugin.php"); if($_REQUEST['id'] && !($plugin=Plugin::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid plugin ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), + __('plugin')); if($_POST) { switch(strtolower($_POST['do'])) { @@ -14,7 +15,8 @@ if($_POST) { break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one plugin'); + $errors['err'] = sprintf(__('You must select at least %s'), + __('one plugin')); } else { $count = count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -44,7 +46,8 @@ if($_POST) { break; case 'install': if ($ost->plugins->install($_POST['install_path'])) - $msg = __('Plugin successfully installed'); + $msg = sprintf(__('Successfully installed %s'), + __('a plugin')); break; } } diff --git a/scp/profile.php b/scp/profile.php index 3796ae1ad..0914c49d8 100644 --- a/scp/profile.php +++ b/scp/profile.php @@ -23,7 +23,7 @@ if($_POST && $_POST['id']!=$thisstaff->getId()) { //Check dummy ID used on the f } elseif(!$errors && $_POST) { //Handle post if(!$staff) - $errors['err']=__('Unknown or invalid agent.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('agent')); elseif($staff->updateProfile($_POST,$errors)){ $msg=__('Profile updated successfully'); $thisstaff->reload(); diff --git a/scp/settings.php b/scp/settings.php index da250fa24..c4e3c9669 100644 --- a/scp/settings.php +++ b/scp/settings.php @@ -42,7 +42,7 @@ if (isset($settingOptions[$target])) if($page && $_POST && !$errors) { if($cfg && $cfg->updateSettings($_POST,$errors)) { - $msg=sprintf(__('%s Updated Successfully'), Format::htmlchars($page[0])); + $msg=sprintf(__('Successfully updated %s'), Format::htmlchars($page[0])); $cfg->reload(); } elseif(!$errors['err']) { $errors['err']=__('Unable to update settings - correct errors below and try again'); diff --git a/scp/slas.php b/scp/slas.php index 92fda7308..b47c73092 100644 --- a/scp/slas.php +++ b/scp/slas.php @@ -18,30 +18,37 @@ include_once(INCLUDE_DIR.'class.sla.php'); $sla=null; if($_REQUEST['id'] && !($sla=SLA::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid API key ID.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), + __('SLA plan')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$sla){ - $errors['err']=__('Unknown or invalid SLA plan.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), + __('SLA plan')); }elseif($sla->update($_POST,$errors)){ - $msg=__('SLA plan updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this SLA plan')); }elseif(!$errors['err']){ - $errors['err']=__('Error updating SLA plan. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this SLA plan')); } break; case 'add': if(($id=SLA::create($_POST,$errors))){ - $msg=__('SLA plan added successfully'); + $msg=sprintf(__('Successfully added %s'), + __('a SLA plan')); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add SLA plan. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this SLA plan')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one plan.'); + $errors['err'] = sprintf(__('You must select at least %s.'), + __('one SLA plan')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -51,11 +58,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected SLA plans enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); else - $warn = sprintf(__('%1$d of %2$d selected SLA plans enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected SLA plan', 'selected SLA plans', $count)); } else { - $errors['err'] = __('Unable to enable selected SLA plans.'); + $errors['err'] = sprintf(__('Unable to enable %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); } break; case 'disable': @@ -63,11 +73,14 @@ if($_POST){ .' WHERE id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected SLA plans disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); else - $warn = sprintf(__('%1$d of %2$d selected SLA plans disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected SLA plan', 'selected SLA plans', $count)); } else { - $errors['err'] = __('Unable to disable selected SLA plans'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); } break; case 'delete': @@ -80,11 +93,14 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected SLA plans deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected SLA plans deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected SLA plan', 'selected SLA plans', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected SLA plans'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected SLA plan', 'selected SLA plans', $count)); break; default: $errors['err']=__('Unknown action - get technical help.'); @@ -92,7 +108,7 @@ if($_POST){ } break; default: - $errors['err']=__('Unknown action/command'); + $errors['err']=__('Unknown action'); break; } } diff --git a/scp/staff.php b/scp/staff.php index 71bb7c3e0..0ad72c2a1 100644 --- a/scp/staff.php +++ b/scp/staff.php @@ -17,30 +17,34 @@ require('admin.inc.php'); $staff=null; if($_REQUEST['id'] && !($staff=Staff::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid agent.'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('agent')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$staff){ - $errors['err']=__('Unknown or invalid agent.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('agent')); }elseif($staff->update($_POST,$errors)){ - $msg=__('Agent updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this agent')); }elseif(!$errors['err']){ - $errors['err']=__('Unable to update agent. Correct any error(s) below and try again!'); + $errors['err']=sprintf(__('Unable to update %s. Correct error(s) below and try again!'), + __('this agent')); } break; case 'create': if(($id=Staff::create($_POST,$errors))){ - $msg=sprintf(__('%s added successfully'),Format::htmlchars($_POST['firstname'])); + $msg=sprintf(__('Successfully added %s'),Format::htmlchars($_POST['firstname'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add agent. Correct any error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this agent')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one agent.'); + $errors['err'] = sprintf(__('You must select at least %s.'), + __('one agent')); } elseif(in_array($thisstaff->getId(),$_POST['ids'])) { $errors['err'] = __('You can not disable/delete yourself - you could be the only admin!'); } else { @@ -52,11 +56,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = _N('Selected agent activated', 'Selected agents activated', $count); + $msg = sprintf('Successfully activated %s', + _N('selected agent', 'selected agents', $count)); else - $warn = sprintf(__('%1$d of %2$d selected agents activated'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s activated'), $num, $count, + _N('selected agent', 'selected agents', $count)); } else { - $errors['err'] = __('Unable to activate selected agents'); + $errors['err'] = sprintf(__('Unable to activate %s'), + _N('selected agent', 'selected agents', $count)); } break; case 'disable': @@ -65,11 +72,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = _N('Selected agent disabled', 'Selected agents disabled', $count); + $msg = sprintf('Successfully disabled %s', + _N('selected agent', 'selected agents', $count)); else - $warn = sprintf(__('%1$d of %2$d selected agents disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected agent', 'selected agents', $count)); } else { - $errors['err'] = __('Unable to disable selected agents'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected agent', 'selected agents', $count)); } break; case 'delete': @@ -79,14 +89,17 @@ if($_POST){ } if($i && $i==$count) - $msg = _N('Selected agent deleted successfully', 'Selected agents deleted successfully', $count); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected agent', 'selected agents', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected agents deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected agent', 'selected agents', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected agents.'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected agent', 'selected agents', $count)); break; default: - $errors['err'] = __('Unknown action. Get technical help!'); + $errors['err'] = __('Unknown action - get technical help.'); } } diff --git a/scp/teams.php b/scp/teams.php index f78dfe1f0..215e9fb87 100644 --- a/scp/teams.php +++ b/scp/teams.php @@ -17,30 +17,33 @@ require('admin.inc.php'); $team=null; if($_REQUEST['id'] && !($team=Team::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid team.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('team')); if($_POST){ switch(strtolower($_POST['do'])){ case 'update': if(!$team){ - $errors['err']=__('Unknown or invalid team.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('team')); }elseif($team->update($_POST,$errors)){ - $msg=__('Team updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this team')); }elseif(!$errors['err']){ - $errors['err']=__('Unable to update team. Correct any error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to update %s. Correct any error(s) below and try again.'), + __('this team')); } break; case 'create': if(($id=Team::create($_POST,$errors))){ - $msg=sprintf(__('%s added successfully'),Format::htmlchars($_POST['team'])); + $msg=sprintf(__('Successfully added %s'),Format::htmlchars($_POST['team'])); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add team. Correct any error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this team')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err']=__('You must select at least one team.'); + $errors['err']=sprintf(__('You must select at least %s.'), __('one team')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -50,11 +53,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected teams activated'); + $msg = sprintf(__('Successfully activated %s'), + _N('selected team', 'selected teams', $count)); else - $warn = sprintf(__('%1$d of %2$d selected teams activated'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s activated'), $num, $count, + _N('selected team', 'selected teams', $count)); } else { - $errors['err'] = __('Unable to activate selected teams'); + $errors['err'] = sprintf(__('Unable to activate %s'), + _N('selected team', 'selected teams', $count)); } break; case 'disable': @@ -63,11 +69,14 @@ if($_POST){ if(db_query($sql) && ($num=db_affected_rows())) { if($num==$count) - $msg = __('Selected teams disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected team', 'selected teams', $count)); else - $warn = sprintf(__('%1$d of %2$d selected teams disabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $num, $count, + _N('selected team', 'selected teams', $count)); } else { - $errors['err'] = __('Unable to disable selected teams'); + $errors['err'] = sprintf(__('Unable to disable %s'), + _N('selected team', 'selected teams', $count)); } break; case 'delete': @@ -76,19 +85,22 @@ if($_POST){ $i++; } if($i && $i==$count) - $msg = __('Selected teams deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected team', 'selected teams', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected teams deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected team', 'selected teams', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected teams'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected team', 'selected teams', $count)); break; default: - $errors['err'] = __('Unknown action. Get technical help!'); + $errors['err'] = __('Unknown action - get technical help.'); } } break; default: - $errors['err']=__('Unknown action/command'); + $errors['err']=__('Unknown action'); break; } } diff --git a/scp/templates.php b/scp/templates.php index d86de5614..34f8b23ea 100644 --- a/scp/templates.php +++ b/scp/templates.php @@ -19,10 +19,10 @@ include_once(INCLUDE_DIR.'class.template.php'); $template=null; if($_REQUEST['tpl_id'] && !($template=EmailTemplateGroup::lookup($_REQUEST['tpl_id']))) - $errors['err']=__('Unknown or invalid template set.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('template set')); elseif($_REQUEST['id'] && !($template=EmailTemplate::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid template.'); + $errors['err']=sprintf(__('%s: Unknown or invalid %s'), __('template')); elseif($_REQUEST['default_for']) { $sql = 'SELECT id FROM '.EMAIL_TEMPLATE_TABLE .' WHERE tpl_id='.db_input($cfg->getDefaultTemplateId()) @@ -35,50 +35,59 @@ if($_POST){ switch(strtolower($_POST['do'])){ case 'updatetpl': if(!$template){ - $errors['err']=__('Unknown or invalid template.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), + __('message template')); }elseif($template->update($_POST,$errors)){ - $msg=__('Message template updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + __('this message template')); // Drop drafts for this template for ALL users Draft::deleteForNamespace('tpl.'.$template->getCodeName() .'.'.$template->getTplId()); }elseif(!$errors['err']){ - $errors['err']=__('Error updating message template. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this template')); } break; case 'implement': if(!$template){ - $errors['err']=__('Unknown or invalid template'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('template set')); }elseif($new = EmailTemplate::add($_POST,$errors)){ $template = $new; - $msg=__('Message template updated successfully'); + $msg=sprintf(__('Successfully updated %s'), __('this message template')); // Drop drafts for this user for this template Draft::deleteForNamespace('tpl.'.$new->getCodeName() .$new->getTplId(), $thisstaff->getId()); }elseif(!$errors['err']){ - $errors['err']=__('Error updating message template. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this message template')); } break; case 'update': if(!$template){ - $errors['err']=__('Unknown or invalid template'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), __('template set')); }elseif($template->update($_POST,$errors)){ - $msg=__('Template updated successfully'); + $msg=sprintf(__('Successfully updated %s'), + mb_convert_case(__('this message template'), MB_CASE_TITLE)); }elseif(!$errors['err']){ - $errors['err']=__('Error updating template. Try again!'); + $errors['err']=sprintf(__('Error updating %s. Try again!'), + __('this message template')); } break; case 'add': if(($new=EmailTemplateGroup::add($_POST,$errors))){ $template=$new; - $msg=__('Template added successfully'); + $msg=sprintf(__('Successfully added %s'), + mb_convert_case(__('a template set'), MB_CASE_TITLE)); $_REQUEST['a']=null; }elseif(!$errors['err']){ - $errors['err']=__('Unable to add template. Correct error(s) below and try again.'); + $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this template set')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err']=__('You must select at least one template to process.'); + $errors['err']=sprintf(__('You must select at least %s to process.'), + __('one template set')); } else { $count=count($_POST['ids']); switch(strtolower($_POST['a'])) { @@ -87,11 +96,14 @@ if($_POST){ .' WHERE tpl_id IN ('.implode(',', db_input($_POST['ids'])).')'; if(db_query($sql) && ($num=db_affected_rows())){ if($num==$count) - $msg = __('Selected templates enabled'); + $msg = sprintf(__('Successfully enabled %s'), + _N('selected template set', 'selected template sets', $count)); else - $warn = sprintf(__('%1$d of %2$d selected templates enabled'), $num, $count); + $warn = sprintf(__('%1$d of %2$d %3$s enabled'), $num, $count, + _N('selected template set', 'selected template sets', $count)); } else { - $errors['err'] = __('Unable to enable selected templates'); + $errors['err'] = sprintf(__('Unable to enable %s'), + _N('selected template set', 'selected template sets', $count)); } break; case 'disable': @@ -101,11 +113,16 @@ if($_POST){ $i++; } if($i && $i==$count) - $msg = __('Selected templates disabled'); + $msg = sprintf(__('Successfully disabled %s'), + _N('selected template set', 'selected template sets', $count)); elseif($i) - $warn = sprintf(__('%1$d of %2$d selected template sets disabled (in-use templates cannot be disabled)'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s disabled'), $i, $count, + _N('selected template set', 'selected template sets', $count)) + .' '.__('(in-use and default template sets cannot be disabled)'); else - $errors['err'] = __("Unable to disable selected template sets (in-use or default template cannot be disabled)"); + $errors['err'] = sprintf(__("Unable to disable %s"), + _N('selected template set', 'selected template sets', $count)) + .' '.__('(in-use and default template sets cannot be disabled)'); break; case 'delete': $i=0; @@ -115,14 +132,17 @@ if($_POST){ } if($i && $i==$count) - $msg = __('Selected templates deleted successfully'); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected template set', 'selected template sets', $count)); elseif($i>0) - $warn = sprintf(__('%1$d of %2$d selected templates deleted'), $i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'), $i, $count, + _N('selected template set', 'selected template sets', $count)); elseif(!$errors['err']) - $errors['err'] = __('Unable to delete selected templates'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected template set', 'selected template sets', $count)); break; default: - $errors['err']=__('Unknown template action'); + $errors['err']=__('Unknown action - get technical help.'); } } break; diff --git a/scp/tickets.php b/scp/tickets.php index 269105c8a..579664d06 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -27,7 +27,7 @@ $ticket = $user = null; //clean start. //LOCKDOWN...See if the id provided is actually valid and if the user has access. if($_REQUEST['id']) { if(!($ticket=Ticket::lookup($_REQUEST['id']))) - $errors['err']=__('Unknown or invalid ticket ID'); + $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('ticket')); elseif(!$ticket->checkStaffAccess($thisstaff)) { $errors['err']=__('Access denied. Contact admin if you believe this is in error'); $ticket=null; //Clear ticket obj. @@ -391,7 +391,8 @@ if($_POST && !$errors): if(!$thisstaff->canManageTickets()) $errors['err']=__('You do not have permission to mass manage tickets. Contact admin for such access'); elseif(!$_POST['tids'] || !is_array($_POST['tids'])) - $errors['err']=__('No tickets selected. You must select at least one ticket.'); + $errors['err']=sprintf(__('You must select at least %s.'), + __('one ticket')); else { $count=count($_POST['tids']); $i = 0; @@ -407,11 +408,14 @@ if($_POST && !$errors): } if($i==$count) - $msg = sprintf(__('Selected tickets %d reopened successfully'),$i); + $msg = sprintf(__('Successfully reopened %s'), + _N('selected ticket', 'selected tickets', $count)); elseif($i) - $warn = sprintf(__('%1$d of %2$d selected tickets reopened'),$i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s reopened'),$i, $count, + _N('selected ticket', 'selected tickets', $count)); else - $errors['err'] = __('Unable to reopen selected tickets'); + $errors['err'] = sprintf(__('Unable to reopen %s'), + _N('selected ticket', 'selected tickets', $count)); } else { $errors['err'] = __('You do not have permission to reopen tickets'); } @@ -427,11 +431,14 @@ if($_POST && !$errors): } if($i==$count) - $msg =sprintf(__('Selected tickets (%d) closed successfully'),$i); + $msg =sprintf(__('Successfully closed %s'), + _N('selected ticket', 'selected tickets', $count)); elseif($i) - $warn = sprintf(__('%1$d of %2$d selected tickets closed'),$i, $count); + $warn = sprintf(__('%1$d of %2$d %s closed'),$i, $count, + _N('selected ticket', 'selected tickets', $count)); else - $errors['err'] = __('Unable to close selected tickets'); + $errors['err'] = sprintf(__('Unable to close %s'), + _N('selected ticket', 'selected tickets', $count)); } else { $errors['err'] = __('You do not have permission to close tickets'); } @@ -460,24 +467,27 @@ if($_POST && !$errors): //Log a warning if($i) { - $log = sprintf(__('%1$s (%2$s) just deleted %3$d ticket(s)'), + $log = sprintf(_S('%1$s (%2$s) just deleted %3$d ticket(s)'), $thisstaff->getName(), $thisstaff->getUserName(), $i); - $ost->logWarning(__('Tickets deleted'), $log, false); + $ost->logWarning(_S('Tickets deleted'), $log, false); } if($i==$count) - $msg = sprintf(__('Selected tickets (%d) deleted successfully'),$i); + $msg = sprintf(__('Successfully deleted %s'), + _N('selected ticket', 'selected tickets', $count)); elseif($i) - $warn = sprintf(__('%1$d of %2$d selected tickets deleted'),$i, $count); + $warn = sprintf(__('%1$d of %2$d %3$s deleted'),$i, $count, + _N('selected ticket', 'selected tickets', $count)); else - $errors['err'] = __('Unable to delete selected tickets'); + $errors['err'] = sprintf(__('Unable to delete %s'), + _N('selected ticket', 'selected tickets', $count)); } else { $errors['err'] = __('You do not have permission to delete tickets'); } break; default: - $errors['err']=__('Unknown or unsupported action - get technical help.'); + $errors['err']=__('Unknown action - get technical help.'); } } break; diff --git a/scp/users.php b/scp/users.php index 052e20d8b..ade247413 100644 --- a/scp/users.php +++ b/scp/users.php @@ -18,35 +18,38 @@ require_once INCLUDE_DIR.'class.note.php'; $user = null; if ($_REQUEST['id'] && !($user=User::lookup($_REQUEST['id']))) - $errors['err'] = __('Unknown or invalid user.'); + $errors['err'] = sprintf(__('%s: Unknown or invalid'), _N('end user', 'end users', 1)); if ($_POST) { switch(strtolower($_REQUEST['do'])) { case 'update': if (!$user) { - $errors['err']=__('Unknown or invalid user.'); + $errors['err']=sprintf(__('%s: Unknown or invalid'), _N('end user', 'end users', 1)); } elseif(($acct = $user->getAccount()) && !$acct->update($_POST, $errors)) { $errors['err']=__('Unable to update user account information'); } elseif($user->updateInfo($_POST, $errors)) { - $msg=__('User updated successfully'); + $msg=sprintf(__('Successfully updated %s'), __('this end user')); $_REQUEST['a'] = null; } elseif(!$errors['err']) { - $errors['err']=__('Unable to update user profile. Correct any error(s) below and try again!'); + $errors['err']=sprintf(__('Unable to update %s. Correct error(s) below and try again!'), + __('this end user')); } break; case 'create': $form = UserForm::getUserForm()->getForm($_POST); if (($user = User::fromForm($form))) { - $msg = Format::htmlchars(sprintf(__('%s added successfully'), $user->getName())); + $msg = Format::htmlchars(sprintf(__('Successfully added %s'), $user->getName())); $_REQUEST['a'] = null; } elseif (!$errors['err']) { - $errors['err'] = __('Unable to add user. Correct any error(s) below and try again.'); + $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), + __('this end user')); } break; case 'confirmlink': if (!$user || !$user->getAccount()) - $errors['err'] = __('Unknown or invalid user account'); + $errors['err'] = sprintf(__('%s: Unknown or invalid'), + __('end user account')); elseif ($user->getAccount()->isConfirmed()) $errors['err'] = __('Account is already confirmed'); elseif ($user->getAccount()->sendConfirmEmail()) @@ -56,7 +59,7 @@ if ($_POST) { break; case 'pwreset': if (!$user || !$user->getAccount()) - $errors['err'] = __('Unknown or invalid user account'); + $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('end user account')); elseif ($user->getAccount()->sendResetEmail()) $msg = sprintf(__('Account password reset email sent to %s'),$user->getEmail()); else @@ -64,7 +67,8 @@ if ($_POST) { break; case 'mass_process': if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { - $errors['err'] = __('You must select at least one user.'); + $errors['err'] = sprintf(__('You must select at least %s.'), + __('one end user')); } else { $errors['err'] = "Coming soon!"; } @@ -72,8 +76,8 @@ if ($_POST) { case 'import-users': $status = User::importFromPost($_FILES['import'] ?: $_POST['pasted']); if (is_numeric($status)) - $msg = sprintf(_N('Successfully imported %1$d client.', 'Successfully imported %1$d clients.', $status), - $status); + $msg = sprintf(__('Successfully imported %1$d %2$s.'), $status, + _N('end user', 'end users', $status)); else $errors['err'] = $status; break; -- GitLab