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:
Eric Lippmann 2015-07-30 15:47:35 +02:00
parent cf91478b65
commit 219dcdda37
4 changed files with 53 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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
*

View File

@ -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
*/