Fix version access while refreshing translations

This commit is contained in:
Johannes Meyer 2014-08-21 10:06:03 +02:00
parent 36a275371f
commit b36fe5d564

View File

@ -37,12 +37,19 @@ class GettextTranslationHelper
private $moduleMgr; private $moduleMgr;
/** /**
* The current version of IcingaWeb2 * The current version of Icingaweb 2 or of the module the catalog is being created for
* *
* @var string * @var string
*/ */
private $version; private $version;
/**
* The name of the module if any
*
* @var string
*/
private $moduleName;
/** /**
* The locale used by this helper * The locale used by this helper
* *
@ -93,8 +100,7 @@ class GettextTranslationHelper
*/ */
public function __construct(ApplicationBootstrap $bootstrap, $locale) public function __construct(ApplicationBootstrap $bootstrap, $locale)
{ {
$this->version = $bootstrap->getConfig()->app()->global->get('version', '0.1'); $this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules();
$this->moduleMgr = $bootstrap->getModuleManager();
$this->appDir = $bootstrap->getApplicationDir(); $this->appDir = $bootstrap->getApplicationDir();
$this->locale = $locale; $this->locale = $locale;
} }
@ -106,6 +112,7 @@ class GettextTranslationHelper
{ {
$this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_'); $this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_');
$this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_'); $this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_');
$this->version = 'None'; // TODO: Access icinga version from a file or property
$this->moduleDir = null; $this->moduleDir = null;
$this->tablePath = implode( $this->tablePath = implode(
@ -133,6 +140,8 @@ class GettextTranslationHelper
{ {
$this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_'); $this->catalogPath = tempnam(sys_get_temp_dir(), 'IcingaTranslation_');
$this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_'); $this->templatePath = tempnam(sys_get_temp_dir(), 'IcingaPot_');
$this->version = $this->moduleMgr->getModule($module)->getVersion();
$this->moduleName = $this->moduleMgr->getModule($module)->getName();
$this->moduleDir = $this->moduleMgr->getModuleDir($module); $this->moduleDir = $this->moduleMgr->getModuleDir($module);
$this->tablePath = implode( $this->tablePath = implode(
@ -251,7 +260,7 @@ class GettextTranslationHelper
'author_name' => 'FIRST AUTHOR', 'author_name' => 'FIRST AUTHOR',
'author_mail' => 'EMAIL@ADDRESS', 'author_mail' => 'EMAIL@ADDRESS',
'author_year' => 'YEAR', 'author_year' => 'YEAR',
'project_name' => 'Icinga Web 2', 'project_name' => $this->moduleName ? ucfirst($this->moduleName) . ' Module' : 'Icinga Web 2',
'project_version' => $this->version, 'project_version' => $this->version,
'project_bug_mail' => 'dev@icinga.org', 'project_bug_mail' => 'dev@icinga.org',
'pot_creation_date' => date('Y-m-d H:iO'), 'pot_creation_date' => date('Y-m-d H:iO'),