mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 16:54:04 +02:00
commit
f4c7fd5408
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ Icinga Web 2 vendor library Parsedown
|
|||||||
|
|
||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
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 -prv application doc %{buildroot}/%{basedir}
|
||||||
cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli
|
cp -pv etc/bash_completion.d/icingacli %{buildroot}/%{_sysconfdir}/bash_completion.d/icingacli
|
||||||
cp -prv modules/{monitoring,setup,doc,translation} %{buildroot}/%{basedir}/modules
|
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/bin/icingacli %{buildroot}/%{bindir}
|
||||||
cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public
|
cp -pv packages/files/public/index.php %{buildroot}/%{basedir}/public
|
||||||
cp -prv etc/schema %{buildroot}/%{docsdir}
|
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
|
%pre
|
||||||
getent group icingacmd >/dev/null || groupadd -r icingacmd
|
getent group icingacmd >/dev/null || groupadd -r icingacmd
|
||||||
@ -212,6 +212,8 @@ rm -rf %{buildroot}
|
|||||||
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
|
%attr(2775,root,%{icingawebgroup}) %dir %{logdir}
|
||||||
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/setup
|
%attr(2770,root,%{icingawebgroup}) %config(noreplace) %dir %{configdir}/modules/setup
|
||||||
%attr(0660,root,%{icingawebgroup}) %config(noreplace) %{configdir}/modules/setup/config.ini
|
%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}
|
%{docsdir}
|
||||||
%docdir %{docsdir}
|
%docdir %{docsdir}
|
||||||
|
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
@ -46,7 +61,7 @@ class TranslationCommand extends Command
|
|||||||
{
|
{
|
||||||
$enabledModules = $this->app->getModuleManager()->listEnabledModules();
|
$enabledModules = $this->app->getModuleManager()->listEnabledModules();
|
||||||
|
|
||||||
if (!in_array($name, $enabledModules)) {
|
if (! in_array($name, $enabledModules)) {
|
||||||
throw new IcingaException(
|
throw new IcingaException(
|
||||||
'Module with name \'%s\' not found or is not enabled',
|
'Module with name \'%s\' not found or is not enabled',
|
||||||
$name
|
$name
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
@ -71,6 +79,13 @@ class GettextTranslationHelper
|
|||||||
*/
|
*/
|
||||||
private $moduleDir;
|
private $moduleDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the Icinga library
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $libDir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The path to the file catalog
|
* The path to the file catalog
|
||||||
*
|
*
|
||||||
@ -102,9 +117,33 @@ class GettextTranslationHelper
|
|||||||
{
|
{
|
||||||
$this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules();
|
$this->moduleMgr = $bootstrap->getModuleManager()->loadEnabledModules();
|
||||||
$this->appDir = $bootstrap->getApplicationDir();
|
$this->appDir = $bootstrap->getApplicationDir();
|
||||||
|
$this->libDir = $bootstrap->getLibraryDir('Icinga');
|
||||||
$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
|
||||||
*/
|
*/
|
||||||
@ -211,7 +250,12 @@ class GettextTranslationHelper
|
|||||||
private function updateTranslationTable()
|
private function updateTranslationTable()
|
||||||
{
|
{
|
||||||
if (is_file($this->tablePath)) {
|
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 {
|
} else {
|
||||||
if ((!is_dir(dirname($this->tablePath)) && !@mkdir(dirname($this->tablePath), 0755, true)) ||
|
if ((!is_dir(dirname($this->tablePath)) && !@mkdir(dirname($this->tablePath), 0755, true)) ||
|
||||||
!rename($this->templatePath, $this->tablePath)) {
|
!rename($this->templatePath, $this->tablePath)) {
|
||||||
@ -233,7 +277,7 @@ class GettextTranslationHelper
|
|||||||
implode(
|
implode(
|
||||||
' ',
|
' ',
|
||||||
array(
|
array(
|
||||||
'/usr/bin/xgettext',
|
$this->getConfig()->get('translation', 'xgettext', '/usr/bin/env xgettext'),
|
||||||
'--language=PHP',
|
'--language=PHP',
|
||||||
'--keyword=translate',
|
'--keyword=translate',
|
||||||
'--keyword=translate:1,2c',
|
'--keyword=translate:1,2c',
|
||||||
@ -360,7 +404,7 @@ class GettextTranslationHelper
|
|||||||
$this->getSourceFileNames($this->moduleDir, $catalog);
|
$this->getSourceFileNames($this->moduleDir, $catalog);
|
||||||
} else {
|
} else {
|
||||||
$this->getSourceFileNames($this->appDir, $catalog);
|
$this->getSourceFileNames($this->appDir, $catalog);
|
||||||
$this->getSourceFileNames(realpath($this->appDir . '/../library/Icinga'), $catalog);
|
$this->getSourceFileNames($this->libDir, $catalog);
|
||||||
}
|
}
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
throw $error;
|
throw $error;
|
||||||
@ -414,7 +458,7 @@ class GettextTranslationHelper
|
|||||||
implode(
|
implode(
|
||||||
' ',
|
' ',
|
||||||
array(
|
array(
|
||||||
'/usr/bin/msgfmt',
|
$this->getConfig()->get('translation', 'msgfmt', '/usr/bin/env msgfmt'),
|
||||||
'-o ' . $targetPath,
|
'-o ' . $targetPath,
|
||||||
$this->tablePath
|
$this->tablePath
|
||||||
)
|
)
|
||||||
|
4
packages/files/config/modules/translation/config.ini
Normal file
4
packages/files/config/modules/translation/config.ini
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[translation]
|
||||||
|
msgmerge = /usr/bin/msgmerge
|
||||||
|
xgettext = /usr/bin/xgettext
|
||||||
|
msgfmt = /usr/bin/msgfmt
|
Loading…
x
Reference in New Issue
Block a user