/** * Detects the most suitable output format to use. * * @param $currentDomain * @return string * @internal param string $domain */ private function detectOutputFormat($currentDomain) { if (null !== $this->config->getOutputFormat()) { return $this->config->getOutputFormat(); } // check if which translation files in which format exist $otherDomainFormat = $localeFormat = $otherLocaleFormat = null; foreach (FileUtils::findTranslationFiles($this->config->getTranslationsDir()) as $domain => $locales) { foreach ($locales as $locale => $fileData) { list($format, ) = $fileData; if ($currentDomain !== $domain) { $otherDomainFormat = $format; continue 2; } if ($this->config->getLocale() === $locale) { $localeFormat = $format; continue; } $otherLocaleFormat = $format; } } if (null !== $localeFormat) { return $localeFormat; } if (null !== $otherLocaleFormat) { return $otherLocaleFormat; } if (null !== $otherDomainFormat) { return $otherDomainFormat; } return $this->config->getDefaultOutputFormat(); }