]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Convert - to _ in language
authorJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 9 Jun 2017 09:42:04 +0000 (11:42 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Fri, 9 Jun 2017 09:42:09 +0000 (11:42 +0200)
Mostly to increase language supports

src/Wallabag/CoreBundle/Helper/ContentProxy.php
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php

index e4e7fb3183c4bbbabc98918c6f8ba02e69990dee..0c971863bcd670957a7f4c0f6d172d98bebdf4f0 100644 (file)
@@ -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())
index b77e5ec1c591c96369896d29f234b7b8ac0a7156..84faf8d40bf8dff9672042d16a225d0ddfa44e32 100644 (file)
@@ -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',
+            ],
         ];
     }
 
index 01decb23a3f1ed097c97810a5d59121caf83c026..bde0a60011fd1b273f939bad79cc6c64feff453c 100644 (file)
@@ -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');