0
좋은 번들 Prezent를 사용하지만 폴백 로캘을 사용하고 싶지 않습니다. 모든 구성이 등록되어 있으며 문서의 내용은 모두 example에 대해 수행되지만 작동하지는 않습니다. 어쩌면 누군가가이 문제를 겪었을 것입니까?PrezentDoctrineTranslatableBundle 대체 로캘이 없음
좋은 번들 Prezent를 사용하지만 폴백 로캘을 사용하고 싶지 않습니다. 모든 구성이 등록되어 있으며 문서의 내용은 모두 example에 대해 수행되지만 작동하지는 않습니다. 어쩌면 누군가가이 문제를 겪었을 것입니까?PrezentDoctrineTranslatableBundle 대체 로캘이 없음
해결! 대신에 :
/**
* Translation helper method
*/
public function translate($locale = null)
{
if (null === $locale) {
$locale = $this->currentLocale;
}
if (!$locale) {
throw new \RuntimeException('No locale has been set and currentLocale is empty');
}
if ($this->currentTranslation && $this->currentTranslation->getLocale() === $locale) {
return $this->currentTranslation;
}
if (!$translation = $this->translations->get($locale)) {
$className = $this->getTranslationEntityClass();
$translation = new $className;
$translation->setLocale($locale);
$this->addTranslation($translation);
}
$this->currentTranslation = $translation;
return $translation;
}
사용 대체 로케일이어야합니다 : 우리는 기업을 상속있는 TranslatableEntity.php에서
/**
* Translation helper method that uses a fallback locale
*/
public function translate($locale = null)
{
if (null === $locale) {
$locale = $this->currentLocale;
}
if (!$locale) {
throw new \RuntimeException('No locale has been set and currentLocale is empty');
}
if ($this->currentTranslation && $this->currentTranslation->getLocale() === $locale) {
return $this->currentTranslation;
}
if (!$translation = $this->translations->get($locale)) {
if (!$translation = $this->translations->get($this->fallbackLocale)) {
throw new \RuntimeException('No translation in current or fallback locale');
}
}
$this->currentTranslation = $translation;
return $translation;
}
는
를 번역 할