translation: Set config on the translation helper
Installations from package will provide a config for the translation module which defines the appropriate gettext tools paths. refs #9615
This commit is contained in:
parent
cf91478b65
commit
219dcdda37
|
@ -38,7 +38,7 @@ class CompileCommand extends TranslationCommand
|
|||
{
|
||||
$locale = $this->validateLocaleCode($this->params->shift());
|
||||
|
||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
||||
$helper = $this->getTranslationHelper($locale);
|
||||
$helper->compileIcingaTranslation();
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class CompileCommand extends TranslationCommand
|
|||
$module = $this->validateModuleName($this->params->shift());
|
||||
$locale = $this->validateLocaleCode($this->params->shift());
|
||||
|
||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
||||
$helper = $this->getTranslationHelper($locale);
|
||||
$helper->compileModuleTranslation($module);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class RefreshCommand extends TranslationCommand
|
|||
{
|
||||
$locale = $this->validateLocaleCode($this->params->shift());
|
||||
|
||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
||||
$helper = $this->getTranslationHelper($locale);
|
||||
$helper->updateIcingaTranslations();
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ class RefreshCommand extends TranslationCommand
|
|||
$module = $this->validateModuleName($this->params->shift());
|
||||
$locale = $this->validateLocaleCode($this->params->shift());
|
||||
|
||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
||||
$helper = $this->getTranslationHelper($locale);
|
||||
$helper->updateModuleTranslations($module);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,27 @@ namespace Icinga\Module\Translation\Cli;
|
|||
use Exception;
|
||||
use Icinga\Cli\Command;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Module\Translation\Util\GettextTranslationHelper;
|
||||
|
||||
/**
|
||||
* Base class for translation commands
|
||||
*/
|
||||
class TranslationCommand extends Command
|
||||
{
|
||||
/**
|
||||
* Get the gettext translation helper
|
||||
*
|
||||
* @param string $locale
|
||||
*
|
||||
* @return GettextTranslationHelper
|
||||
*/
|
||||
public function getTranslationHelper($locale)
|
||||
{
|
||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
||||
$helper->setConfig($this->Config());
|
||||
return $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given locale code is valid
|
||||
*
|
||||
|
@ -46,7 +61,7 @@ class TranslationCommand extends Command
|
|||
{
|
||||
$enabledModules = $this->app->getModuleManager()->listEnabledModules();
|
||||
|
||||
if (!in_array($name, $enabledModules)) {
|
||||
if (! in_array($name, $enabledModules)) {
|
||||
throw new IcingaException(
|
||||
'Module with name \'%s\' not found or is not enabled',
|
||||
$name
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
namespace Icinga\Module\Translation\Util;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Application\Modules\Manager;
|
||||
use Icinga\Exception\IcingaException;
|
||||
use Icinga\Util\File;
|
||||
use Icinga\Application\Modules\Manager;
|
||||
use Icinga\Application\ApplicationBootstrap;
|
||||
|
||||
/**
|
||||
* This class provides some useful utility functions to handle gettext translations
|
||||
|
@ -19,6 +20,13 @@ class GettextTranslationHelper
|
|||
*/
|
||||
const FILE_ENCODING = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* The source files to parse
|
||||
*
|
||||
|
@ -105,6 +113,29 @@ class GettextTranslationHelper
|
|||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the config
|
||||
*
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the config
|
||||
*
|
||||
* @param Config $config
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConfig(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the translation table for the main application
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue