Skip to content
Snippets Groups Projects
Commit 6f84397b authored by Jared Hancock's avatar Jared Hancock
Browse files

i18n: Add translations for popups and login dialog

parent 6cf4c2d8
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ class OrgsAjaxAPI extends AjaxController {
Http::response(404, 'Unknown organization');
$info = array(
'title' => sprintf('Update %s', $org->getName())
'title' => sprintf(__('Update %s'), $org->getName())
);
$forms = $org->getForms();
......@@ -119,7 +119,7 @@ class OrgsAjaxAPI extends AjaxController {
Http::response(404, 'Unknown organization');
$info = array();
$info['title'] = 'Add User';
$info['title'] = __('Add User');
$info['action'] = '#orgs/'.$org->getId().'/add-user';
$info['onselect'] = 'ajax.php/orgs/'.$org->getId().'/add-user/';
......@@ -130,20 +130,20 @@ class OrgsAjaxAPI extends AjaxController {
if ($_POST) {
if ($_POST['id']) { //Existing useer
if (!($user = User::lookup($_POST['id'])))
$info['error'] = 'Unknown user selected';
$info['error'] = __('Unknown user selected');
elseif ($user->getOrgId() == $org->getId())
$info['error'] = sprintf('%s already belongs to the organization',
Format::htmlchars($user->getName()));
} else { //Creating new user
$form = UserForm::getUserForm()->getForm($_POST);
if (!($user = User::fromForm($form)))
$info['error'] = 'Error adding user - try again!';
$info['error'] = __('Error adding user - try again!');
}
if (!$info['error'] && $user && $user->setOrganization($org))
Http::response(201, $user->to_json());
elseif (!$info['error'])
$info['error'] = 'Unable to add user to the organization - try again';
$info['error'] = __('Unable to add user to the organization - try again');
} elseif ($remote && $userId) {
list($bk, $userId) = explode(':', $userId, 2);
......@@ -157,9 +157,9 @@ class OrgsAjaxAPI extends AjaxController {
if ($user && $user->getOrgId()) {
if ($user->getOrgId() == $org->getId())
$info['warn'] = 'User already belongs to this organization!';
$info['warn'] = __('User already belongs to this organization!');
else
$info['warn'] = "Are you sure you want to change the user's organization?";
$info['warn'] = __("Are you sure you want to change the user's organization?");
}
ob_start();
......@@ -178,7 +178,7 @@ class OrgsAjaxAPI extends AjaxController {
Http::response(404, 'No such organization');
$info = array(
'title' => 'Import Users',
'title' => __('Import Users'),
'action' => "#orgs/$org_id/import-users",
'upload_url' => "orgs.php?a=import-users",
);
......@@ -204,10 +204,10 @@ class OrgsAjaxAPI extends AjaxController {
if (($org = Organization::fromForm($form)))
Http::response(201, $org->to_json());
$info = array('error' =>'Error adding organization - try again!');
$info = array('error' =>__('Error adding organization - try again!'));
}
$info['title'] = 'Add New Organization';
$info['title'] = __('Add New Organization');
$info['search'] = false;
return self::_lookupform($form, $info);
......@@ -221,7 +221,7 @@ class OrgsAjaxAPI extends AjaxController {
if ($id) $org = Organization::lookup($id);
$info = array('title' => 'Select Organization');
$info = array('title' => __('Select Organization'));
ob_start();
include(STAFFINC_DIR . 'templates/org-lookup.tmpl.php');
......@@ -243,7 +243,7 @@ class OrgsAjaxAPI extends AjaxController {
static function _lookupform($form=null, $info=array()) {
if (!$info or !$info['title'])
$info += array('title' => 'Organization Lookup');
$info += array('title' => __('Organization Lookup'));
ob_start();
include(STAFFINC_DIR . 'templates/org-lookup.tmpl.php');
......
......@@ -113,7 +113,7 @@ class UsersAjaxAPI extends AjaxController {
Http::response(404, 'Unknown user');
$info = array(
'title' => sprintf('Update %s', $user->getName())
'title' => sprintf(__('Update %s'), $user->getName())
);
$forms = $user->getForms();
......@@ -148,7 +148,7 @@ class UsersAjaxAPI extends AjaxController {
if ($_POST) {
// Register user on post
if ($user->getAccount())
$info['error'] = 'User already registered';
$info['error'] = __('User already registered');
elseif ($user->register($_POST, $errors))
Http::response(201, 'Account created successfully');
......@@ -157,7 +157,7 @@ class UsersAjaxAPI extends AjaxController {
if ($errors['err'])
$info['error'] = $errors['err'];
else
$info['error'] = 'Unable to register user - try again!';
$info['error'] = __('Unable to register user - try again!');
}
include(STAFFINC_DIR . 'templates/user-register.tmpl.php');
......@@ -187,7 +187,7 @@ class UsersAjaxAPI extends AjaxController {
if ($errors['err'])
$info['error'] = $errors['err'];
else
$info['error'] = 'Unable to update account - try again!';
$info['error'] = __('Unable to update account - try again!');
}
$info['_target'] = $target;
......@@ -207,19 +207,19 @@ class UsersAjaxAPI extends AjaxController {
if ($_POST) {
if ($user->tickets->count()) {
if (!$thisstaff->canDeleteTickets()) {
$info['error'] = 'You do not have permission to delete a user with tickets!';
$info['error'] = __('You do not have permission to delete a user with tickets!');
} elseif ($_POST['deletetickets']) {
foreach($user->tickets as $ticket)
$ticket->delete();
} else {
$info['error'] = 'You cannot delete a user with tickets!';
$info['error'] = __('You cannot delete a user with tickets!');
}
}
if (!$info['error'] && $user->delete())
Http::response(204, 'User deleted successfully');
elseif (!$info['error'])
$info['error'] = 'Unable to delete user - try again!';
$info['error'] = __('Unable to delete user - try again!');
}
include(STAFFINC_DIR . 'templates/user-delete.tmpl.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' => __('Unknown or invalid user'));
return self::_lookupform(null, $info);
}
......@@ -247,12 +247,12 @@ class UsersAjaxAPI extends AjaxController {
$info['lookup'] = 'local';
if ($_POST) {
$info['title'] = 'Add New User';
$info['title'] = __('Add New User');
$form = UserForm::getUserForm()->getForm($_POST);
if (($user = User::fromForm($form)))
Http::response(201, $user->to_json());
$info['error'] = 'Error adding user - try again!';
$info['error'] = __('Error adding user - try again!');
}
return self::_lookupform($form, $info);
......@@ -270,9 +270,11 @@ class UsersAjaxAPI extends AjaxController {
Http::response(404, 'User not found');
$form = UserForm::getUserForm()->getForm($user_info);
$info = array('title' => 'Import Remote User');
$info = array('title' => __(
/* `remote` users are those in a remore directory such as LDAP */
'Import Remote User'));
if (!$user_info)
$info['error'] = 'Unable to find user in directory';
$info['error'] = __('Unable to find user in directory');
include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php');
}
......@@ -284,7 +286,7 @@ class UsersAjaxAPI extends AjaxController {
Http::response(403, 'Login Required');
$info = array(
'title' => 'Import Users',
'title' => __('Import Users'),
'action' => '#users/import',
'upload_url' => "users.php?do=import-users",
);
......@@ -306,7 +308,7 @@ class UsersAjaxAPI extends AjaxController {
if ($id)
$user = User::lookup($id);
$info = array('title' => 'Select User');
$info = array('title' => __('Select User'));
ob_start();
include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php');
......@@ -319,7 +321,7 @@ class UsersAjaxAPI extends AjaxController {
static function _lookupform($form=null, $info=array()) {
if (!$info or !$info['title'])
$info += array('title' => 'Lookup or create a user');
$info += array('title' => __('Lookup or create a user'));
ob_start();
include(STAFFINC_DIR . 'templates/user-lookup.tmpl.php');
......@@ -357,24 +359,24 @@ class UsersAjaxAPI extends AjaxController {
Http::response(404, 'Unknown user');
$info = array();
$info['title'] = 'Organization for '.$user->getName();
$info['title'] = sprintf(__('Organization for %s'), $user->getName());
$info['action'] = '#users/'.$user->getId().'/org';
$info['onselect'] = 'ajax.php/users/'.$user->getId().'/org';
if ($_POST) {
if ($_POST['orgid']) { //Existing org.
if (!($org = Organization::lookup($_POST['orgid'])))
$info['error'] = 'Unknown organization selected';
$info['error'] = __('Unknown organization selected');
} 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 - 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 organization - try again!');
} elseif ($orgId)
$org = Organization::lookup($orgId);
......
......@@ -10,8 +10,8 @@ $info = ($_POST && $errors)?Format::htmlchars($_POST):array();
<?php csrf_token(); ?>
<input type="hidden" name="do" value="scplogin">
<fieldset>
<input type="text" name="userid" id="name" value="<?php echo $info['userid']; ?>" placeholder="username" autocorrect="off" autocapitalize="off">
<input type="password" name="passwd" id="pass" placeholder="password" autocorrect="off" autocapitalize="off">
<input type="text" name="userid" id="name" value="<?php echo $info['userid']; ?>" placeholder="<?php echo __('Email or Username'); ?>" autocorrect="off" autocapitalize="off">
<input type="password" name="passwd" id="pass" placeholder="<?php echo __('Password'); ?>" autocorrect="off" autocapitalize="off">
<?php if ($show_reset && $cfg->allowPasswordReset()) { ?>
<h3 style="display:inline"><a href="pwreset.php"><?php echo __('Forgot my password'); ?></a></h3>
<?php } ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment