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;
}
的用途必须退区域:
/**
* 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;
}
在TranslatableEntity.php
从中继承实体被翻译