I have a i18n project running on Symfony 4.1.
I want to achieve some routing like:
Following this article, I'm using annotations to handle routing and I set a global prefix to my annotations routing :
site:
resource: '../src/Controller/'
type: annotation
prefix:
en: '/en'
fr: '/fr'
This way, all the routes defined in annotations from '../src/Controller/' are prefixed, which leads to a conflict between my "Choose language" page and the homepage.
I want to exclude the "Choose language" page from the i18n prefixing, so I'll be able to use "/" for this page, when the homepage could stay on /fr or /en.
Any ideas to achieve this?
Defining this route at top of annotations.yaml
without prefix option:
_choose_language:
path: /
controller: App\Controller\ChooseLanguageController
site:
resource: '../src/Controller/'
type: annotation
prefix:
en: '/en'
fr: '/fr'
and don't use route annotation for this special controller:
class ChooseLanguageController
{
public function __invoke()
{
return new Response('Choose Language!');
}
}
then this action is being excluded from i18n prefixing.