Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/remmel/host-per-locale-sf51
Demo project to test Symfony 5.1 i18n routes
https://github.com/remmel/host-per-locale-sf51
Last synced: about 1 month ago
JSON representation
Demo project to test Symfony 5.1 i18n routes
- Host: GitHub
- URL: https://github.com/remmel/host-per-locale-sf51
- Owner: remmel
- License: mit
- Created: 2020-06-27T23:28:15.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-09-30T20:39:50.000Z (over 2 years ago)
- Last Synced: 2023-03-12T04:48:10.911Z (almost 2 years ago)
- Language: PHP
- Size: 116 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# host-per-locale-sf51
Objective : be able to handle such urls for a website in 4 languages (fr_BE, nl_BE, de, en):
- www.website.de/kontakt
- www.website.com/contact
- www.website.be/fr/nous-contacter
- www.website.be/nl/contacteer-onsThis is currenlty possible using my package [remmel/i18n-routing-bundle](https://packagist.org/packages/remmel/i18n-routing-bundle) (check [demo](https://github.com/remmel/i18n-routing-demo)). But here, we will use the new symfony features :
- [Symfony 4.1: Internationalized routing](https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing) (url prefix + translation)
- [Symfony 5.1: Different hosts per locale](https://symfony.com/blog/new-in-symfony-5-1-different-hosts-per-locale)However, some optinal functionalities are still missing from Symfony (but present in my [remmel/i18n-routing-bundle](https://packagist.org/packages/remmel/i18n-routing-bundle) ) :
- Externalize url translation in `translations/routes.de.yaml`
- Merge prefix + host to shorten the configurationCurrently `annotations.yaml`
```
controllers:
resource: ../../src/Controller/
type: annotation
host:
fr_BE: www.website.be
nl_BE: www.website.be
en: www.website.com
de: www.website.de
prefix:
fr_BE: '/fr'
nl_BE: '/nl'
en: ''
de: ''
```It would be great to have something like :
```
controllers:
resource: ../../src/Controller/
type: annotation
locales:
fr_BE: www.website.be/fr/
nl_BE: www.website.be/bl/
en: www.website.com
de: www.website.de
```Generated routes of that project: `bin/console debug:router`
```
-------------------------- -------- -------- ----------------- -----------------------------------
Name Method Scheme Host Path
-------------------------- -------- -------- ----------------- -----------------------------------
home.fr_BE ANY ANY www.website.be /fr/
home.nl_BE ANY ANY www.website.be /nl/
home.en ANY ANY www.website.com /
home.de ANY ANY www.website.de /
contact.en ANY ANY www.website.com /contact
contact.de ANY ANY www.website.de /kontakt
contact.fr_BE ANY ANY www.website.be /fr/nous-contacter
contact.nl_BE ANY ANY www.website.be /nl/contacteer-ons
-------------------------- -------- -------- ----------------- -----------------------------------
```