Routes Symfony 5-国际化路线-带有空或动态区域设置的前缀路线
以下宣言正在发挥作用:Routes Symfony 5-国际化路线-带有空或动态区域设置的前缀路线,routes,locale,symfony5,Routes,Locale,Symfony5,以下宣言正在发挥作用: app_localized: resource: "../src/Controller/" type: annotation prefix: en: '' # don't prefix URLs for English, the default locale de: '/de' es: '/es' 因此,我们可以访问以下URL: / /德 /es 但我不想在支持的语言发生变化
app_localized:
resource: "../src/Controller/"
type: annotation
prefix:
en: '' # don't prefix URLs for English, the default locale
de: '/de'
es: '/es'
因此,我们可以访问以下URL:
- /
- /德
- /es
app_localized:
resource: "../src/Controller/"
type: annotation
prefix:
en: '' # don't prefix URLs for English, the default locale
'*': {_locale}
因此,可以访问以下URL:
- /
- /德
- /es
- /nl
- /fr
- 还有更多
^[a-z]{2}([-])?([a-Za-z]{2})?$
有什么办法解决这个问题吗?我通常定义两个路由:一个用于非固定路由,另一个用于前缀路由 像这样的东西可能有用
app_localized:
resource: "../src/Controller/"
type: annotation
prefix: '/{_locale}'
name_prefix: 'localized_'
app_default:
resource: "../src/Controller/"
type: annotation
prefix: '/'
name_prefix: 'default_'
defaults:
_locale: en