use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Tools\Utils;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
-use Symfony\Component\Validator\Constraints\Language as LanguageConstraint;
+use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
use Symfony\Component\Validator\Validator\ValidatorInterface;
$this->validateAndSetLanguage(
$entry,
- isset($content['language']) ? $content['language'] : ''
+ isset($content['language']) ? $content['language'] : null
);
$this->validateAndSetPreviewPicture(
$entry,
- isset($content['open_graph']['og_image']) ? $content['open_graph']['og_image'] : ''
+ isset($content['open_graph']['og_image']) ? $content['open_graph']['og_image'] : null
);
// if content is an image, define it as a preview too
*/
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 LanguageConstraint())
+ (new LocaleConstraint())
);
if (0 === count($errors)) {