public function validate($value, $minLength = null, $maxLength = null, $allowLinebreaks = false)
 {
     // make sure there are no untranslated parts at the beginning, unless the string is entirely empty
     if ($value !== "") {
         $this->regexValidator->validate($value, "|^\\[:[a-z]{2}\\]|");
     }
     $availableLanguages = array_map(function ($locale) {
         return substr($locale, 0, 2);
     }, $this->localeService->getAvailableLocales());
     $parts = Multilang::multilangStringToArray($value);
     if (!count($parts) && $minLength) {
         throw new InvalidValueException(Translate::t("The field must be translated into at least one language."));
     }
     foreach ($parts as $lang => $string) {
         if (!in_array($lang, $availableLanguages)) {
             throw new InvalidValueException(sprintf(Translate::t("`%s` is not a valid language."), $lang));
         }
         if ($string || $minLength) {
             $this->stringValidator->validate($string, $minLength, $maxLength, $allowLinebreaks);
         }
     }
 }
 /**
  * @dataProvider providerTestMultilangStringToArray
  */
 public function testMultilangStringToObject($string, $expected)
 {
     $this->assertSame($expected, Multilang::multilangStringToArray($string));
 }