Překlad pole v Error Presenteru
- mat.cerny3
- Člen | 9
Zdravím…
Projížděl jsem fórum a nějakej se furt nemohu dostat k překladu error presenteru.
ErrorPresenter
<?php
namespace App\AdminModule\Presenters;
use Nette;
use Nette\Application;
use Nette\Http;
use Tracy\ILogger;
/**
* Default Error Presenter.
*/
class ErrorPresenter implements Application\IPresenter
{
use Nette\SmartObject;
/** @var ILogger|null */
private $logger;
public function __construct(ILogger $logger = null)
{
$this->logger = $logger;
}
/**
* @return Application\IResponse
*/
public function run(Application\Request $request)
{
$e = $request->getParameter('exception');
if ($e instanceof Application\BadRequestException) {
$code = $e->getHttpCode();
} else {
$code = 500;
if ($this->logger) {
$this->logger->log($e, ILogger::EXCEPTION);
}
}
return new Application\Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse) use ($code) {
if (preg_match('#^text/html(?:;|$)#', $httpResponse->getHeader('Content-Type'))) {
require __DIR__ . '\..\templates\error.latte';
}
});
}
}
error.latte
<?php
/**
* Default error page.
* @param int $code
*/
namespace NetteModule;
$messages = [
0 => ['Oops...', 'Your browser sent a request that this server could not understand or process.'],
403 => ['Access Denied', 'You do not have permission to view this page. Please try contact the web site administrator if you believe you should be able to view this page.'],
404 => ['Page Not Found', 'The page you requested could not be found. It is possible that the address is incorrect, or that the page no longer exists. Please use a search engine to find what you are looking for.'],
405 => ['Method Not Allowed', 'The requested method is not allowed for the URL.'],
410 => ['Page Not Found', 'The page you requested has been taken off the site. We apologize for the inconvenience.'],
500 => ['Server Error', 'We\'re sorry! The server encountered an internal error and was unable to complete your request. Please try again later.'],
];
$message = isset($messages[$code]) ? $messages[$code] : $messages[0];
?>
<!DOCTYPE html>
<meta charset="utf-8">
<meta name=robots content=noindex>
<meta name=generator content="Nette Framework">
<div id="notfound">
<div class="notfound">
<div class="notfound-404">
<h1>Oops!</h1>
<h2><?= $message[0] ?></h2>
</div>
<h2><?php if ($code): ?><p><small>error <?= $code ?></small></p><?php endif ?></h2>
<p><?= $message[1] ?></p>
<a href="#">Go TO Homepage</a>
</div>
</div>
Jde mi o to, že potřebuji přeložit zprávy, které se nachází v latte souboru. Zkoušel jsem pole přeložit pomocí {_Preklad}, ale nepovedlo se mi to a potřebuji poradit jak to zrealizovat.
- mat.cerny3
- Člen | 9
A mohu se zeptat na nějakou dokumentaci nebo fóra kde bych se dočetl jak to udělat?