Used twig extension to load translations on twig templates

This commit is contained in:
Alejandro Celaya 2016-07-21 16:54:00 +02:00
parent e42469b090
commit fb9c7f8eec
5 changed files with 57 additions and 8 deletions

View file

@ -0,0 +1,14 @@
<?php
return [
'translator' => [
'translation_file_patterns' => [
[
'type' => 'gettext',
'base_dir' => __DIR__ . '/../lang',
'pattern' => '%s.mo',
],
],
],
];

BIN
module/Core/lang/es.mo Normal file

Binary file not shown.

35
module/Core/lang/es.po Normal file
View file

@ -0,0 +1,35 @@
msgid ""
msgstr ""
"Project-Id-Version: Shlink 1.0\n"
"POT-Creation-Date: 2016-07-21 16:50+0200\n"
"PO-Revision-Date: 2016-07-21 16:51+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.8.7.1\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: translate;translaePlural;translate_plural\n"
"X-Poedit-SearchPath-0: templates\n"
"X-Poedit-SearchPath-1: config\n"
"X-Poedit-SearchPath-2: src\n"
msgid "Make sure you included all the characters, with no extra punctuation."
msgstr "Asegúrate de haber incluído todos los caracteres, sin puntuación extra."
msgid "Oops!"
msgstr "¡Vaya!"
msgid "This short URL doesn't seem to be valid."
msgstr "Esta URL acortada no parece ser válida."
msgid "URL Not Found"
msgstr "URL no encontrada"
#, php-format
msgid "We encountered a %s %s error."
msgstr "Hemos encontrado un error %s %s."

View file

@ -1,6 +1,6 @@
{% extends 'core/layout/default.html.twig' %}
{% block title %}URL Not Found{% endblock %}
{% block title %}{{ translate('URL Not Found') }}{% endblock %}
{% block stylesheets %}
<style>
@ -10,8 +10,8 @@
{% endblock %}
{% block content %}
<h1>Oops!</h1>
<h1>{{ translate('Oops!') }}</h1>
<hr>
<p>This short URL doesn't seem to be valid.</p>
<p>Make sure you included all the characters, with no extra punctuation.</p>
<p>{{ translate('This short URL doesn\'t seem to be valid.') }}</p>
<p>{{ translate('Make sure you included all the characters, with no extra punctuation.') }}</p>
{% endblock %}

View file

@ -10,11 +10,11 @@
{% endblock %}
{% block content %}
<h1>Oops!</h1>
<h1>{{ translate('Oops!') }}</h1>
<hr>
<p>We encountered a {{ status }} {{ reason }} error.</p>
<p>{{ translate('We encountered a %s %s error.') | format(status, reason) }}</p>
{% if status == 404 %}
<p>This short URL doesn't seem to be valid.</p>
<p>Make sure you included all the characters, with no extra punctuation.</p>
<p>{{ translate('This short URL doesn\'t seem to be valid.') }}</p>
<p>{{ translate('Make sure you included all the characters, with no extra punctuation.') }}</p>
{% endif %}
{% endblock %}