From 80e49ba7b0320a5c4278c01f3d7851a9218e0919 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Jun 2017 11:42:04 +0200 Subject: Convert - to _ in language Mostly to increase language supports --- src/Wallabag/CoreBundle/Helper/ContentProxy.php | 4 ++++ tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 12 ++++++++---- .../ImportBundle/Controller/ReadabilityControllerTest.php | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index e4e7fb31..0c971863 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -174,6 +174,10 @@ class ContentProxy */ private function validateAndSetLanguage($entry, $value) { + // some lang are defined as fr-FR, es-ES. + // replacing - by _ might increase language support + $value = str_replace('-', '_', $value); + $errors = $this->validator->validate( $value, (new LocaleConstraint()) diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index b77e5ec1..84faf8d4 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -1252,9 +1252,9 @@ class EntryControllerTest extends WallabagCoreTestCase 'https://www.pravda.ru/world/09-06-2017/1337283-qatar-0/', 'ru', ], - 'wrong fr-FR' => [ - 'http://www.zataz.com/fff-darknet/axzz4jUg2QJjH', - '', + 'fr-FR' => [ + 'http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', + 'fr_FR', ], 'de' => [ 'http://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html', @@ -1280,10 +1280,14 @@ class EntryControllerTest extends WallabagCoreTestCase 'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa', 'pt_BR', ], - 'fucked list of languages' => [ + 'fucked_list_of_languages' => [ 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home', '', ], + 'es-ES' => [ + 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google', + 'es_ES', + ], ]; } diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 01decb23..bde0a600 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php @@ -120,7 +120,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); - $this->assertEmpty($content->getLanguage(), 'Language for http://www.zataz.com is empty because not valid (fr-FR)'); + $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); $tags = $content->getTags(); $this->assertContains('foot', $tags, 'It includes the "foot" tag'); -- cgit v1.2.3