Skip to content

Commit

Permalink
Merge pull request #5 from samwilson/lang-loading
Browse files Browse the repository at this point in the history
Add missing i18n message and unify error display
  • Loading branch information
ramack committed Sep 7, 2019
2 parents b625daa + 617a181 commit f51a80f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
3 changes: 2 additions & 1 deletion language/en_UK/plugin.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
$lang['Rotate clockwise'] = 'Rotate clockwise';
$lang['Rotate counterclockwise'] = 'Rotate counterclockwise';
$lang['Rotate HD Images'] = 'Rotate HD Images';
?>
$lang['To install this plugin, you need to install the rotateImage plugin first.'] = 'To install this plugin, you need to install the rotateImage plugin first.';
?>
42 changes: 22 additions & 20 deletions maintain.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ function __construct($plugin_id)
$this->rotateImage_installed = file_exists(PHPWG_PLUGINS_PATH . 'rotateImage/main.inc.php')?true:false;
}

/**
* Add an error message about the imageRotate plugin not being installed.
*
* @param string[] $errors The error array to add to.
*/
protected function addRotateImageError(&$errors)
{
load_language('plugin.lang', __DIR__ . '/');
$msg = sprintf(l10n('To install this plugin, you need to install the rotateImage plugin first.'));
if(is_array($errors))
{
array_push($errors, $msg);
}
else
{
$errors = array($msg);
}
}

/**
* Plugin installation
*
Expand All @@ -37,16 +56,7 @@ function install($plugin_version, &$errors=array())

if (!$this->rotateImage_installed)
{
$msg = sprintf(l10n('To install this plugin, you need to install the rotateImage plugin first.'));
if(is_array($errors))
{
array_push($errors, $msg);
}
else
{
$errors = Array($msg);
}
$result = false;
$this->addRotateImageError($errors);
}
else
{
Expand Down Expand Up @@ -90,15 +100,7 @@ function activate($plugin_version, &$errors=array())

if (!$this->rotateImage_installed || !$rotateImage_active)
{
$msg = sprintf(l10n('To install this plugin, you need to install and activate the rotateImage plugin first.'));
if(is_array($errors))
{
array_push($errors, $msg);
}
else
{
$errors = Array($msg);
}
$this->addRotateImageError($errors);
}
}

Expand Down Expand Up @@ -143,4 +145,4 @@ function uninstall()
}
rmdir($this->dir);
}
}
}

0 comments on commit f51a80f

Please sign in to comment.