KnpLabs / DoctrineBehaviors可翻译 - currentLocale = null

时间:2013-10-23 11:53:47

标签: symfony doctrine behavior

使用Entity中的特征\Knp\DoctrineBehaviors\Model\Translatable\Translation,我发现永远不会设置属性currentLocale,所以我们总是在$this->translate()的所有调用中获得默认的语言环境('en')。

如果我更改了这个getDefaultLocale,所有翻译都是正确的,所以我认为回退没有问题。

我尝试调试currentLocaleCallable。我看到如果我输入“var_dump($ this-> container-> get('request'));”在currentLocaleCallable的构造函数中,请求具有null的区域设置。在请求之外有正确的locale.It似乎容器不在范围内:请求,我不知道如何让它工作

我在github https://github.com/KnpLabs/DoctrineBehaviors/issues/71

中发布了一个问题

EDITED

此服务在vendor / knplabs / doctrine-behavior / config / orm-services.yml中定义,并且是:

knp.doctrine_behaviors.reflection.class_analyzer:
    class:   "%knp.doctrine_behaviors.reflection.class_analyzer.class%"
    public:  false

knp.doctrine_behaviors.translatable_listener:
    class:   "%knp.doctrine_behaviors.translatable_listener.class%"
    public:  false
    arguments:
        - "@knp.doctrine_behaviors.reflection.class_analyzer"
        - "%knp.doctrine_behaviors.reflection.is_recursive%"
        - "@knp.doctrine_behaviors.translatable_listener.current_locale_callable"
    tags:
        - { name: doctrine.event_subscriber }

knp.doctrine_behaviors.translatable_listener.current_locale_callable:
    class:           "%knp.doctrine_behaviors.translatable_listener.current_locale_callable.class%"
    arguments:
        - "@service_container" # lazy request resolution
    public:  false

编辑2:我的composer.json

    "php": ">=5.3.3",
    "symfony/symfony": "2.3.*",
    "doctrine/orm": ">=2.2.3,<2.4-dev",
    "doctrine/doctrine-bundle": "1.2.*",
    "twig/extensions": "1.0.*",
    "symfony/assetic-bundle": "2.3.*",
    "symfony/swiftmailer-bundle": "2.3.*",
    "symfony/monolog-bundle": "2.3.*",
    "sensio/distribution-bundle": "2.3.*",
    "sensio/framework-extra-bundle": "2.3.*",
    "sensio/generator-bundle": "2.3.*",
    "incenteev/composer-parameter-handler": "~2.0",        
    "friendsofsymfony/user-bundle": "1.3.*",
    "avalanche123/imagine-bundle": "v2.1",
    "raulfraile/ladybug-bundle": "~1.0",
    "genemu/form-bundle": "2.2.*",
    "friendsofsymfony/rest-bundle": "0.12.0",
    "stof/doctrine-extensions-bundle": "dev-master",
    "sonata-project/admin-bundle": "dev-master",
    "a2lix/translation-form-bundle": "1.*@dev",
    "sonata-project/user-bundle": "dev-master",
    "psliwa/pdf-bundle": "dev-master",
    "jms/serializer-bundle": "dev-master",
    "jms/di-extra-bundle": "dev-master",
    "knplabs/doctrine-behaviors": "dev-master",
    "sonata-project/doctrine-orm-admin-bundle": "dev-master",
    "knplabs/knp-paginator-bundle": "dev-master",
    "friendsofsymfony/jsrouting-bundle": "~1.1",
    "zendframework/zend-validator": ">=2.0.0-rc2",
    "zendframework/zend-barcode": ">=2.0.0-rc2"

0 个答案:

没有答案