1. Go to this page and download the library: Download carlosv2/translatte library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
carlosv2 / translatte example snippets
class HelloWorldTranslation implements TranslationInterface
{
public function matches($message)
{
return $message === 'Hello World';
}
public function translate($message)
{
return 'Hola Mundo';
}
}
class FileTranslation implements TranslationInterface
{
public function matches($message)
{
return file_exists($message);
}
public function translate($message)
{
return file_get_contents($message);
}
}
$translator = new Translator();
$translator->addTranslation(new HelloWorldTranslation());
$translator->addTranslation(new FileTranslation());
echo $translator->translate('Hello World'); // Hola Mundo
echo $translator->translate('/etc/passwd'); // The contents of your file
class LoadRowSql extends SqlToRawTranslation
{
private $data;
public function __construct(array $data)
{
$this->data = $data;
}
protected function getSqlPattern()
{
return 'SELECT {*} FROM my_table WHERE field = {field}';
}
protected function process($field)
{
return $this->data[$field];
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.