dev-master
9999999-devSimple example of multilingual routing and translating
MIT
The Requires
The Development Requires
by Igor Staroverov
Wallogit.com
2017 © Pedro Peláez
Simple example of multilingual routing and translating
Multilingual Routing Bundle for the Symfony Framework, (*1)
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)
$ composer require inwaar/multilingual-routing-bundle:dev-master
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:, (*4)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new MultilingualRoutingBundle\MultilingualRoutingBundle(),
);
// ...
}
// ...
}
# app/config/config.yml
multilingual_routing:
map:
en: com
en_GB: co.uk
The map is optional., (*5)
Add type: localized to the route definition, so the root route (/) will be appended by {_locale}., (*6)
# app/config/routing.yml
app:
resource: "@AppBundle/Resources/config/routing.yml"
prefix: /
type: localized
Or, (*7)
# app/config/config.yml
framework:
router:
type: localized
resource: '%kernel.root_dir%/routing.yml'
Or configure the route manually., (*8)
Make sure all domains point to the host you run the app. Or add a list to your local host config., (*9)
# /etc/host 127.0.0.1 example.com 127.0.0.1 example.nl 127.0.0.1 example.fr 127.0.0.1 example.us 127.0.0.1 example.co.uk
https://github.com/inwaar/multilingual-routing-example, (*10)
Simple example of multilingual routing and translating
MIT