add module to compile .po files
parent
a83f9bf702
commit
99df49aa52
|
@ -33,7 +33,7 @@ class improve
|
|||
{
|
||||
/** @var array Allowed file extensions to open */
|
||||
private static $readfile_extensions = [
|
||||
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md',
|
||||
'php', 'xml', 'js', 'css', 'csv', 'html', 'htm', 'txt', 'md', 'po',
|
||||
];
|
||||
|
||||
/** @var array<action> $actions Loaded actions modules */
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<?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);
|
||||
|
||||
namespace plugins\improve\module;
|
||||
|
||||
/* improve */
|
||||
use plugins\improve\action;
|
||||
|
||||
/* clearbricks */
|
||||
use l10n;
|
||||
|
||||
/* php */
|
||||
|
||||
/**
|
||||
* Improve action module dcstore.xml
|
||||
*/
|
||||
class po2php extends action
|
||||
{
|
||||
/** @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;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: improve 0.10\n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2022-12-03T22:40:15+00:00\n"
|
||||
"PO-Revision-Date: 2022-12-21T11:10:34+00:00\n"
|
||||
"Last-Translator: Jean-Christian Denis\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -316,6 +316,18 @@ msgstr "Aucune erreur trouvé"
|
|||
msgid "Failed to run phpstan"
|
||||
msgstr "Impossible d'exécuter PHPStan"
|
||||
|
||||
msgid "Translation files"
|
||||
msgstr "Fichier de traductions"
|
||||
|
||||
msgid "Compile existing translation .po files to fresh .lang.php files"
|
||||
msgstr "Compile les fichiers de traductions .po existants en fichiers compilés .lang.php"
|
||||
|
||||
msgid "Compile .po file to .lang.php"
|
||||
msgstr "Fichier .po compilé en .lang.php"
|
||||
|
||||
msgid "Failed to compile .po file"
|
||||
msgstr "Impossible de compiler le fichier .po"
|
||||
|
||||
msgid "Tabulations"
|
||||
msgstr "Tabulations"
|
||||
|
||||
|
|
Loading…
Reference in New Issue