translater/inc/lib.translater.proposal.php

119 lines
2.2 KiB
PHP
Raw Normal View History

2021-08-18 19:42:30 +00:00
<?php
2021-09-02 21:44:01 +00:00
/**
* @brief translater, a plugin for Dotclear 2
2021-11-01 21:32:32 +00:00
*
2021-09-02 21:44:01 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-01 21:32:32 +00:00
*
2021-09-02 21:44:01 +00:00
* @author Jean-Christian Denis & contributors
2021-11-01 21:32:32 +00:00
*
2021-09-02 21:44:01 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-08-18 19:42:30 +00:00
/**
* Translater proposal tool.
*
* Generic class to provide translation tool
*/
abstract class translaterProposalTool
{
2021-08-18 22:48:47 +00:00
private $active = false;
2021-11-01 21:32:32 +00:00
private $name = 'unknow';
private $desc = 'no description';
2021-08-18 22:48:47 +00:00
/**
Constructor
2021-11-01 21:32:32 +00:00
*/
2022-11-13 17:40:31 +00:00
final public function __construct()
2021-08-18 22:48:47 +00:00
{
$this->setup();
}
/**
Set name of this tool
2021-09-02 21:44:01 +00:00
2022-11-13 17:40:31 +00:00
@param string $name Tool's name
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final protected function setName($name)
{
$this->name = (string) $name;
}
/**
Get name of this tool
2021-09-02 21:44:01 +00:00
2021-08-18 22:48:47 +00:00
@return string Tool's name
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final public function getName()
{
return $this->name;
}
/**
Set description of this tool
2021-09-02 21:44:01 +00:00
2022-11-13 17:40:31 +00:00
@param string $desc Tool's description
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final protected function setDesc($desc)
{
$this->desc = (string) $desc;
}
/**
Get description of this tool
2021-09-02 21:44:01 +00:00
2021-08-18 22:48:47 +00:00
@return string Tool's description
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final public function getDesc()
{
return $this->desc;
}
/**
Set tool as (un)active
2021-09-02 21:44:01 +00:00
2022-11-13 17:40:31 +00:00
@param boolean $active True to set it as active
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final protected function setActive($active)
{
2021-11-05 00:21:33 +00:00
$this->active = (bool) $active;
2021-08-18 22:48:47 +00:00
}
/**
Check if this tool is active
2021-09-02 21:44:01 +00:00
2021-08-18 22:48:47 +00:00
@return boolean True if it is active
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
final public function isActive()
{
return $this->active;
}
/**
Set tool's info - using setName(),setDesc(),setActive()
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
abstract protected function setup();
/**
Get configuration interface
2021-09-02 21:44:01 +00:00
2022-11-13 17:40:31 +00:00
@return string Form field
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
abstract public function form();
/**
Save configuration
2021-11-01 21:32:32 +00:00
*/
2021-08-18 22:48:47 +00:00
abstract public function save();
/**
Translate a string from a language to another
2021-09-02 21:44:01 +00:00
2021-08-18 22:48:47 +00:00
@param string $str Trimed UTF-8 string to translate
@param string $from Source language code
2022-11-13 17:40:31 +00:00
@param string $to Destination language code
@return string Translated string
2021-11-01 21:32:32 +00:00
*/
abstract public function translate($str, $from, $to);
}