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());
|
$locale = $this->validateLocaleCode($this->params->shift());
|
||||||
|
|
||||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
$helper = $this->getTranslationHelper($locale);
|
||||||
$helper->compileIcingaTranslation();
|
$helper->compileIcingaTranslation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class CompileCommand extends TranslationCommand
|
||||||
$module = $this->validateModuleName($this->params->shift());
|
$module = $this->validateModuleName($this->params->shift());
|
||||||
$locale = $this->validateLocaleCode($this->params->shift());
|
$locale = $this->validateLocaleCode($this->params->shift());
|
||||||
|
|
||||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
$helper = $this->getTranslationHelper($locale);
|
||||||
$helper->compileModuleTranslation($module);
|
$helper->compileModuleTranslation($module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class RefreshCommand extends TranslationCommand
|
||||||
{
|
{
|
||||||
$locale = $this->validateLocaleCode($this->params->shift());
|
$locale = $this->validateLocaleCode($this->params->shift());
|
||||||
|
|
||||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
$helper = $this->getTranslationHelper($locale);
|
||||||
$helper->updateIcingaTranslations();
|
$helper->updateIcingaTranslations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class RefreshCommand extends TranslationCommand
|
||||||
$module = $this->validateModuleName($this->params->shift());
|
$module = $this->validateModuleName($this->params->shift());
|
||||||
$locale = $this->validateLocaleCode($this->params->shift());
|
$locale = $this->validateLocaleCode($this->params->shift());
|
||||||
|
|
||||||
$helper = new GettextTranslationHelper($this->app, $locale);
|
$helper = $this->getTranslationHelper($locale);
|
||||||
$helper->updateModuleTranslations($module);
|
$helper->updateModuleTranslations($module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,27 @@ namespace Icinga\Module\Translation\Cli;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Cli\Command;
|
use Icinga\Cli\Command;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
|
use Icinga\Module\Translation\Util\GettextTranslationHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for translation commands
|
* Base class for translation commands
|
||||||
*/
|
*/
|
||||||
class TranslationCommand extends Command
|
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
|
* Check whether the given locale code is valid
|
||||||
*
|
*
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
namespace Icinga\Module\Translation\Util;
|
namespace Icinga\Module\Translation\Util;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Icinga\Application\ApplicationBootstrap;
|
||||||
|
use Icinga\Application\Config;
|
||||||
|
use Icinga\Application\Modules\Manager;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Util\File;
|
use Icinga\Util\File;
|
||||||
use Icinga\Application\Modules\Manager;
|
|
||||||
use Icinga\Application\ApplicationBootstrap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides some useful utility functions to handle gettext translations
|
* This class provides some useful utility functions to handle gettext translations
|
||||||
|
@ -19,6 +20,13 @@ class GettextTranslationHelper
|
||||||
*/
|
*/
|
||||||
const FILE_ENCODING = 'UTF-8';
|
const FILE_ENCODING = 'UTF-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config
|
||||||
|
*
|
||||||
|
* @var Config
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The source files to parse
|
* The source files to parse
|
||||||
*
|
*
|
||||||
|
@ -105,6 +113,29 @@ class GettextTranslationHelper
|
||||||
$this->locale = $locale;
|
$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
|
* Update the translation table for the main application
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue