Symfony2 Sylius设置默认语言环境

时间:2015-09-30 09:06:06

标签: symfony sylius

当我想创建货件时,我收到错误:

An exception has been thrown during the rendering of a template ("No locale has been set and current locale is undefined.") in SonataAdminBundle::standard_layout.html.twig at line 148.

我想我需要为sylius设置默认语言环境,但我尝试了很多例子,没有一个帮助..

我目前有这样的设置:

Config.yml:

sylius_shipping:
    driver: doctrine/orm # Configure the Doctrine ORM driver used in documentation.
    classes:
        shipping_method:
            model: Application\Sylius\ShippingBundle\Entity\ShippingMethod
            translation:
                model: Application\Sylius\ShippingBundle\Entity\ShippingMethodTranslation
        shipping_method_rule:
            model: Application\Sylius\ShippingBundle\Entity\Rule
        shipment:
            model: Application\Sylius\ShippingBundle\Entity\Shipment
        shipment_item:
            model: Application\Sylius\ShippingBundle\Entity\ShipmentItem
        shipping_category:
            model: Application\Sylius\ShippingBundle\Entity\ShippingCategory

#stof_doctrine_extensions:
#    orm:
#        default:
#            timestampable: true

parameters:
    sylius.locale: %locale%

#sylius_locale:
#    driver: doctrine/orm

sylius_translation:
    default_locale: "%locale%"



#sylius_translation:
#    default_locale: %sylius.locale%

Parameters.yml:

sylius.currency_importer.ecb.base_currency: EUR
sylius.currency_importer.open_exchange_rates: EDITME
sylius.locale: en_US

没有任何作用..

更新

将我的配置更改为:

framework:
    #esi:             ~
    translator:      { fallback: %sylius.locale% }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%sylius.locale%"

parameters:
    sylius.locale: 'en'

#sylius_locale:
#    driver: doctrine/orm

sylius_translation:
    default_locale: %sylius.locale%

我仍然得到同样的错误。我清除了缓存。

1 个答案:

答案 0 :(得分:0)

试试%sylius.locale%。看起来您还没有在配置文件中输入参数的全名。

如果您已更新了该值并且该值无效,请确保清除缓存。

$ app/console cache/clear --env=dev
$ app/console cache/clear --env=prod

你还需要这样的东西:

imports:
- { resource: parameters.yml }

否则您输入的参数将不会加载到配置文件中。