Merge pull request #483 from acelaya-forks/feature/remoive-translations

Feature/remoive translations
This commit is contained in:
Alejandro Celaya 2019-09-12 20:30:45 +02:00 committed by GitHub
commit d17533fd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 43 additions and 110 deletions

View file

@ -5,10 +5,6 @@ SHORTENED_URL_SCHEMA=
SHORTENED_URL_HOSTNAME=
SHORTCODE_CHARS=
# Language
DEFAULT_LOCALE=
CLI_LOCALE=
# Database
DB_USER=
DB_PASSWORD=

View file

@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* [#435](https://github.com/shlinkio/shlink/issues/435) Removed translations for error pages. All error pages are in english now.
#### Fixed
* *Nothing*
## 1.18.1 - 2019-08-24
#### Added

View file

@ -33,7 +33,7 @@
"ocramius/proxy-manager": "~2.2.2",
"phly/phly-event-dispatcher": "^1.0",
"predis/predis": "^1.1",
"shlinkio/shlink-common": "^1.0",
"shlinkio/shlink-common": "^2.0",
"shlinkio/shlink-event-dispatcher": "^1.0",
"shlinkio/shlink-installer": "^1.2.1",
"shlinkio/shlink-ip-geolocation": "^1.0",
@ -50,7 +50,6 @@
"zendframework/zend-expressive-helpers": "^5.3",
"zendframework/zend-expressive-platesrenderer": "^2.1",
"zendframework/zend-expressive-swoole": "^2.4",
"zendframework/zend-i18n": "^2.9",
"zendframework/zend-inputfilter": "^2.10",
"zendframework/zend-paginator": "^2.8",
"zendframework/zend-servicemanager": "^3.4",

View file

@ -7,6 +7,7 @@ use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Monolog\Processor;
use Psr\Log\LoggerInterface;
use const PHP_EOL;
@ -61,6 +62,11 @@ return [
'Logger_Shlink' => Common\Logger\LoggerFactory::class,
'Logger_Access' => Common\Logger\LoggerFactory::class,
],
'aliases' => [
'logger' => 'Logger_Shlink',
Logger::class => 'Logger_Shlink',
LoggerInterface::class => 'Logger_Shlink',
],
],
'zend-expressive-swoole' => [

View file

@ -47,9 +47,6 @@ return [
'post-routing' => [
'middleware' => [
Expressive\Router\Middleware\DispatchMiddleware::class,
// Only if a not found error is triggered, set-up the locale to be used
Common\Middleware\LocaleMiddleware::class,
Core\Response\NotFoundHandler::class,
],
'priority' => 1,

View file

@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Common;
return [
'translator' => [
'locale' => Common\env('DEFAULT_LOCALE', 'en'),
],
];

View file

@ -101,7 +101,6 @@ This is the complete list of supported env vars:
* `DB_PORT`: The port in which the database service is running when using an external database driver. Defaults to **3306**.
* `DISABLE_TRACK_PARAM`: The name of a query param that can be used to visit short URLs avoiding the visit to be tracked. This feature won't be available if not value is provided.
* `DELETE_SHORT_URL_THRESHOLD`: The amount of visits on short URLs which will not allow them to be deleted. Defaults to `15`.
* `LOCALE`: Defines the default language for error pages when a user accesses a short URL which does not exist. Supported values are **es** and **en**. Defaults to **en**.
* `VALIDATE_URLS`: Boolean which tells if shlink should validate a status 20x (after following redirects) is returned when trying to shorten a URL. Defaults to `true`.
* `NOT_FOUND_REDIRECT_TO`: If a URL is provided here, when a user tries to access an invalid short URL, he/she will be redirected to this value. If this env var is not provided, the user will see a generic `404 - not found` page.
* `REDIS_SERVERS`: A comma-separated list of redis servers where Shlink locks are stored (locks are used to prevent some operations to be run more than once in parallel).
@ -128,7 +127,6 @@ docker run \
-e DB_PORT=3306 \
-e DISABLE_TRACK_PARAM="no-track" \
-e DELETE_SHORT_URL_THRESHOLD=30 \
-e LOCALE=es \
-e VALIDATE_URLS=false \
-e "NOT_FOUND_REDIRECT_TO=https://www.google.com" \
-e "REDIS_SERVERS=tcp://172.20.0.1:6379,tcp://172.20.0.2:6379" \
@ -147,7 +145,6 @@ The whole configuration should have this format, but it can be split into multip
{
"disable_track_param": "my_param",
"delete_short_url_threshold": 30,
"locale": "es",
"short_domain_schema": "https",
"short_domain_host": "doma.in",
"validate_url": false,

View file

@ -124,10 +124,6 @@ return [
'visits_threshold' => (int) env('DELETE_SHORT_URL_THRESHOLD', 15),
],
'translator' => [
'locale' => env('LOCALE', 'en'),
],
'entity_manager' => [
'connection' => $helper->getDbConfig(),
],

View file

@ -12,8 +12,6 @@ use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Zend\ServiceManager\ServiceManager;
use function array_merge;
class ApplicationFactoryTest extends TestCase
{
/** @var ApplicationFactory */
@ -49,7 +47,7 @@ class ApplicationFactoryTest extends TestCase
{
return new ServiceManager(['services' => [
'config' => [
'cli' => array_merge($config, ['locale' => 'en']),
'cli' => $config,
],
AppOptions::class => new AppOptions(),
]]);

View file

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

Binary file not shown.

View file

@ -1,44 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: Shlink 1.0\n"
"POT-Creation-Date: 2019-04-14 08:58+0200\n"
"PO-Revision-Date: 2019-04-14 08:58+0200\n"
"Last-Translator: Alejandro Celaya <alejandro@alejandrocelaya.com>\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 2.1.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 "URL Not Found"
msgstr "URL no encontrada"
msgid "Page not found."
msgstr "Página no encontrada."
msgid "The page you requested could not be found."
msgstr "La página solicitada no ha podido ser encontrada."
msgid "Oops!"
msgstr "¡Vaya!"
#, php-format
msgid "We encountered a %s %s error."
msgstr "Hemos encontrado un error %s %s."
msgid "This short URL doesn't seem to be valid."
msgstr "Esta URL acortada no parece ser válida."
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 "Invalid URL"
msgstr "URL inválida"

View file

@ -21,7 +21,6 @@ class SimplifiedConfigParser
'not_found_redirect_to' => ['url_shortener', 'not_found_short_url', 'redirect_to'],
'db_config' => ['entity_manager', 'connection'],
'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'],
'locale' => ['translator', 'locale'],
'redis_servers' => ['redis', 'servers'],
];
private const SIMPLIFIED_CONFIG_SIDE_EFFECTS = [

View file

@ -1,7 +1,7 @@
<?php $this->layout('ShlinkCore::layout/default') ?>
<?php $this->start('title') ?>
<?= $this->translate('URL Not Found') ?>
URL Not Found
<?php $this->end() ?>
<?php $this->start('stylesheets') ?>
@ -14,6 +14,6 @@
<?php $this->start('main') ?>
<h1>404</h1>
<hr>
<h3><?= $this->translate('Page not found.') ?></h3>
<p><?= $this->translate('The page you requested could not be found.') ?></p>
<h3>Page not found.</h3>
<p>The page you requested could not be found.</p>
<?php $this->end() ?>

View file

@ -12,14 +12,14 @@
<?php $this->end() ?>
<?php $this->start('main') ?>
<h1><?= $this->translate('Oops!') ?></h1>
<h1>Oops!</h1>
<hr>
<?php if ($status !== 404): ?>
<p><?= sprintf($this->translate('We encountered a %s %s error.'), $status, $reason) ?></p>
<p><?= sprintf('We encountered a %s %s error.', $status, $reason) ?></p>
<?php else: ?>
<p><?= $this->translate('This short URL doesn\'t seem to be valid.') ?></p>
<p><?= $this->translate('Make sure you included all the characters, with no extra punctuation.') ?></p>
<p>'This short URL doesn't seem to be valid.</p>
<p>'Make sure you included all the characters, with no extra punctuation.</p>
<?php endif; ?>
<?php $this->end() ?>

View file

@ -1,7 +1,7 @@
<?php $this->layout('ShlinkCore::layout/default') ?>
<?php $this->start('title') ?>
<?= $this->translate('Invalid URL') ?>
Invalid URL
<?php $this->end() ?>
<?php $this->start('stylesheets') ?>
@ -12,8 +12,8 @@
<?php $this->end() ?>
<?php $this->start('main') ?>
<h1><?= $this->translate('Oops!') ?></h1>
<h1>Oops!</h1>
<hr>
<p><?= $this->translate('This short URL doesn\'t seem to be valid.') ?></p>
<p><?= $this->translate('Make sure you included all the characters, with no extra punctuation.') ?></p>
<p>This short URL doesn't seem to be valid.</p>
<p>Make sure you included all the characters, with no extra punctuation.</p>
<?php $this->end() ?>

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="<?= $this->locale() ?>">
<html lang="en">
<head>
<title><?= $this->section('title', '') ?> | URL shortener</title>
<meta charset="utf-8">

View file

@ -24,7 +24,6 @@ class ConfigProviderTest extends TestCase
$this->assertArrayHasKey('routes', $config);
$this->assertArrayHasKey('dependencies', $config);
$this->assertArrayHasKey('templates', $config);
$this->assertArrayHasKey('translator', $config);
$this->assertArrayHasKey('zend-expressive', $config);
}
}

View file

@ -39,7 +39,6 @@ class SimplifiedConfigParserTest extends TestCase
'short_domain_host' => 'doma.in',
'validate_url' => false,
'delete_short_url_threshold' => 50,
'locale' => 'es',
'not_found_redirect_to' => 'foobar.com',
'redis_servers' => [
'tcp://1.1.1.1:1111',
@ -80,10 +79,6 @@ class SimplifiedConfigParserTest extends TestCase
],
],
'translator' => [
'locale' => 'es',
],
'delete_short_urls' => [
'visits_threshold' => 50,
'check_visits_threshold' => true,