improve/inc/module/po2php.php

76 lines
1.6 KiB
PHP
Raw Normal View History

2022-12-21 13:02:12 +00:00
<?php
/**
* @brief improve, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1);
2022-12-21 14:41:27 +00:00
namespace Dotclear\Plugin\improve\Module;
2022-12-21 13:02:12 +00:00
/* improve */
2022-12-21 14:41:27 +00:00
use Dotclear\Plugin\improve\Action;
2022-12-21 13:02:12 +00:00
/* clearbricks */
use l10n;
/* php */
/**
* Improve action module dcstore.xml
*/
2022-12-21 14:41:27 +00:00
class po2php extends Action
2022-12-21 13:02:12 +00:00
{
/** @var string License bloc */
private $license = <<<EOF
/**
* @package Dotclear
*
* @copyright Olivier Meunier & Association Dotclear
* @copyright GPL-2.0-only
*/
EOF;
/** @var string Settings dcstore zip url pattern */
private $pattern = '';
protected function init(): bool
{
$this->setProperties([
'id' => 'po2php',
'name' => __('Translation files'),
'description' => __('Compile existing translation .po files to fresh .lang.php files'),
'priority' => 310,
'types' => ['plugin', 'theme'],
]);
return true;
}
public function isConfigured(): bool
{
return true;
}
public function closeFile(): ?bool
{
if (!in_array($this->path_extension, ['po'])) {
return null;
}
if (l10n::generatePhpFileFromPo(substr($this->path_full, 0, -3), $this->license)) {
$this->setSuccess(__('Compile .po file to .lang.php'));
} else {
$this->setError(__('Failed to compile .po file'));
}
return true;
}
}