JMS\I18nRoutingBundle
、Gedmo\Translatable
およびを使用してGedmo\Sluggable
います。デフォルトの場所を持つルートも同様に機能しますが、他のロケールは翻訳されたスラッグなしで機能します。私の i18n ルーティングには次の設定があります。
# Doctrine extensions
stof_doctrine_extensions:
default_locale: %locale%
translation_fallback: true
orm:
default:
#…
sluggable: true
translatable: true
loggable: false
#…
jms_i18n_routing:
default_locale: cs_CZ
locales: [cs_CZ, en_US]
strategy: custom
hosts:
cs_CZ: example.cz
en_US: example.com
redirect_to_host: true
次のようにルートを設定すると:
hw_category:
pattern: /category/{slug}
defaults: { _controller: AcmeSiteBundle:Category:detail }
/**
* @Template
*/
public function detailAction(Category $category)
{}
このルートは機能します
example.cz/category/slug-in-czech
example.com/category/slug-in-czech
example.com/category/slug-in-english
しかし、私は 404 例外をスローする作業を取得したいと考えていますobject not found
。