Merge branch 'master' into feature/query-limit-plus-one-9661
This commit is contained in:
commit
60b0b4cc61
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/php
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ Icinga Web 2 vendor library Parsedown
|
|||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
mkdir -p %{buildroot}/{%{basedir}/{modules,library/vendor,public},%{bindir},%{configdir}/modules/setup,%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}}
|
||||
mkdir -p %{buildroot}/{%{basedir}/{modules,library/vendor,public},%{bindir},%{configdir}/modules,%{logdir},%{phpdir},%{wwwconfigdir},%{_sysconfdir}/bash_completion.d,%{docsdir}}
|
||||
cp -prv application doc %{buildroot}/%{basedir}
|
||||
cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli
|
||||
cp -prv modules/{monitoring,setup,doc,translation} %{buildroot}/%{basedir}/modules
|
||||
|
@ -183,7 +183,7 @@ cp -pv packages/files/apache/icingaweb2.conf %{buildroot}/%{wwwconfigdir}/icinga
|
|||
cp -pv packages/files/bin/icingacli %{buildroot}/%{bindir}
|
||||
cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public
|
||||
cp -prv etc/schema %{buildroot}/%{docsdir}
|
||||
cp -prv packages/files/config/modules/setup %{buildroot}/%{configdir}/modules/
|
||||
cp -prv packages/files/config/modules/{setup,translation} %{buildroot}/%{configdir}/modules
|
||||
|
||||
%pre
|
||||
getent group icingacmd >/dev/null || groupadd -r icingacmd
|
||||
|
@ -212,6 +212,8 @@ rm -rf %{buildroot}
|
|||
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
|
||||
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/setup
|
||||
%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup/config.ini
|
||||
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/translation
|
||||
%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/translation/config.ini
|
||||
%{docsdir}
|
||||
%docdir %{docsdir}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
@ -71,6 +79,13 @@ class GettextTranslationHelper
|
|||
*/
|
||||
private $moduleDir;
|
||||
|
||||
/**
|
||||
* Path to the Icinga library
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $libDir;
|
||||
|
||||
/**
|
||||
* The path to the file catalog
|
||||
*
|
||||
|
@ -102,9 +117,33 @@ class GettextTranslationHelper
|
|||
{
|
||||
$this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules();
|
||||
$this->appDir = $bootstrap->getApplicationDir();
|
||||
$this->libDir = $bootstrap->getLibraryDir('Icinga');
|
||||
$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
|
||||
*/
|
||||
|
@ -211,7 +250,12 @@ class GettextTranslationHelper
|
|||
private function updateTranslationTable()
|
||||
{
|
||||
if (is_file($this->tablePath)) {
|
||||
shell_exec(sprintf('/usr/bin/msgmerge --update %s %s 2>&1', $this->tablePath, $this->templatePath));
|
||||
shell_exec(sprintf(
|
||||
'%s --update %s %s 2>&1',
|
||||
$this->getConfig()->get('translation', 'msgmerge', '/usr/bin/env msgmerge'),
|
||||
$this->tablePath,
|
||||
$this->templatePath
|
||||
));
|
||||
} else {
|
||||
if ((!is_dir(dirname($this->tablePath)) && !@mkdir(dirname($this->tablePath), 0755, true)) ||
|
||||
!rename($this->templatePath, $this->tablePath)) {
|
||||
|
@ -233,7 +277,7 @@ class GettextTranslationHelper
|
|||
implode(
|
||||
' ',
|
||||
array(
|
||||
'/usr/bin/xgettext',
|
||||
$this->getConfig()->get('translation', 'xgettext', '/usr/bin/env xgettext'),
|
||||
'--language=PHP',
|
||||
'--keyword=translate',
|
||||
'--keyword=translate:1,2c',
|
||||
|
@ -360,7 +404,7 @@ class GettextTranslationHelper
|
|||
$this->getSourceFileNames($this->moduleDir, $catalog);
|
||||
} else {
|
||||
$this->getSourceFileNames($this->appDir, $catalog);
|
||||
$this->getSourceFileNames(realpath($this->appDir . '/../library/Icinga'), $catalog);
|
||||
$this->getSourceFileNames($this->libDir, $catalog);
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
|
@ -414,7 +458,7 @@ class GettextTranslationHelper
|
|||
implode(
|
||||
' ',
|
||||
array(
|
||||
'/usr/bin/msgfmt',
|
||||
$this->getConfig()->get('translation', 'msgfmt', '/usr/bin/env msgfmt'),
|
||||
'-o ' . $targetPath,
|
||||
$this->tablePath
|
||||
)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
[translation]
|
||||
msgmerge = /usr/bin/msgmerge
|
||||
xgettext = /usr/bin/xgettext
|
||||
msgfmt = /usr/bin/msgfmt
|
Loading…
Reference in New Issue