1

我只是想做一个多语言的应用程序网站,所以我看到了可翻译和其他捆绑。

我使用可翻译和 a2lix ......所以我阅读了文档,但是当我尝试使用 a2lix 时,我收到以下错误消息:

Class c2c\AppBundle\Entity\PeriodTranslation does not exist 500 Internal Server Error - ReflectionException

我将我的 entityTranslation 设置在一个子文件夹中,例如 Entity>Translation>MyEntityTranslation

有没有办法对 a2lix 说...它应该在我的子文件夹中查看?

谢谢您的帮助。

实体

namespace c2c\AppBundle\Entity;

use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Translatable;


/**
 * Period
 *
 * @ORM\Table(name="Periods")
 * @ORM\Entity(repositoryClass="c2c\AppBundle\Entity\PeriodRepository")
 * @Gedmo\TranslationEntity(class="c2c\AppBundle\Entity\Translation\PeriodTranslation")
 */
class Period implements Translatable
...

实体翻译

namespace c2c\AppBundle\Entity\Translation;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;

/**
 * PeriodTranslation is used fo
 *
 * @author blucas
 */


/**
 * @ORM\Table(name="ext_translations_period", indexes={
 *      @ORM\Index(name="period_translation_idx", columns={"locale", "object_class", "field", "foreign_key"})
 * })
 * @ORM\Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
 */
class PeriodTranslation extends AbstractTranslation
{
    /**
     * All required columns are mapped through inherited superclass
     */
}

配置

orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        mappings:
            gedmo_translatable:
                type: annotation
                prefix: Gedmo\Translatable\Entity
                dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                alias: GedmoTranslatable
                is_bundle: false
...
# Soft Doctrine extendions
stof_doctrine_extensions:
    default_locale: en_US

    # Only used if you activated the Uploadable extension
    # uploadable:
        # Default file path: This is one of the three ways you can configure the path for the Uploadable extension
        # default_file_path:       %kernel.root_dir%/../web/uploads

        # Mime type guesser class: Optional. By default, we provide an adapter for the one present in the HttpFoundation component of Symfony
        # mime_type_guesser_class: Stof\DoctrineExtensionsBundle\Uploadable\MimeTypeGuesserAdapter

        # Default file info class implementing FileInfoInterface: Optional. By default we provide a class which is prepared to receive an UploadedFile instance.
        # default_file_info_class: Stof\DoctrineExtensionsBundle\Uploadable\UploadedFileInfo
    orm:
        default:
            #   sluggable: true
            translatable: true

...

# Give a way to translate form
a2lix_translation_form:
    locale_provider: default
    locales: [en,fr,nl]
    default_locale: en
    required_locales: [en]
    manager_registry: doctrine
    templating: "A2lixTranslationFormBundle::default.html.twig"
4

1 回答 1

4

抛出错误是因为最新版本a2lix与稳定版本不兼容Gedmo

检查这个答案https://stackoverflow.com/a/22018321/2160958

如果你想使用 Gedmo 策略,你将不得不降级你的"a2lix/translation-form-bundle""1.*@dev"如果你想使用最新版本,"a2lix/translation-form-bundle"你将不得不使用 wip2.4 Gedmo版本,还不稳定。

检查这个https://github.com/a2lix/TranslationFormBundle/blob/master/UPGRADE-2.0.md

于 2015-02-16T12:07:19.510 回答