A Symfony2 bundle to help you to translate your Symfony2 applications.
There are two modes of install this bundle: in the dev environment (recommended) or in the prod environment (not recommended).
This is the recommended method.
Open a command console, change to your project directory and execute the following command to download the latest version of this bundle:
$ composer require davamigo/translator-bundle dev-master
Note: You can substitute dev-master
for a version number like 1.0.0
or 1.0.x
or ^1.0
or something similar. See Packagist.com or Github.com to chose the right version.
Enable the bundle by adding it to the list of registered bundles in the dev environment of the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles = array_merge($bundles, array(
// ...
new Davamigo\TranslatorBundle\DavamigoTranslatorBundle()
));
}
// ...
}
// ...
}
Load the routes of the bundle by adding this configuration in the the app/config/routing_dev.yml
file:
# app/config/routing_dev.yml
# ...
davamigo_translator:
resource: "@DavamigoTranslatorBundle/Resources/config/routing.yml"
prefix: /translator
# ...
Note: You can change the prefix route /translator
by your own route: /translation
or /admin/translator
or something similar.
This bundle uses some JavaScript, CSS and font files and needs to be added to the assetic section of the app/config/config_dev.yml
file:
# app/config/config_dev.yml
# ...
# Assetic Configuration
assetic:
# ...
bundles: [ '...', 'DavamigoTranslatorBundle' ]
# ...
You must uncomment the translator item in the frameword section of the app/config/config.yml
file:
# app/config/config.yml
# ...
framework:
# ...
translator: { fallbacks: ["%locale%"] }
# ...
This installation is not recommended.
Open a command console, change to your project directory and execute the following command to download the latest version of this bundle:
$ composer require davamigo/translator-bundle dev-master
Note: You can substitute dev-master
for a version number like 1.0.0
or 1.0.x
or ^1.0
or something similar. See Packagist.com or Github.com to chose the right version.
Enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Davamigo\TranslatorBundle\DavamigoTranslatorBundle()
);
// ...
}
// ...
}
Load the routes of the bundle by adding this configuration in the the app/config/routing.yml
file:
# app/config/routing.yml
# ...
davamigo_translator:
resource: "@DavamigoTranslatorBundle/Resources/config/routing.yml"
prefix: /translator
# ...
Note: You can change the prefix route /translator
by your own route: /translation
or /admin/translator
or something similar.
This step is optional but strongly recommended.
# app/config/security.yml
security:
# ...
access_control:
- { path: "^/translator", role: ROLE_ADMIN }
# ...
Note: If you changed the route in the step 4, you must change the route here too.
This bundle uses some JavaScript, CSS and font files and needs to be added to the assetic section of the app/config/config.yml
file:
# app/config/config.yml
# ...
# Assetic Configuration
assetic:
# ...
bundles: [ '...', 'DavamigoTranslatorBundle' ]
# ...
You must uncomment the translator item in the frameword section of the app/config/config.yml
file:
# app/config/config.yml
# ...
framework:
# ...
translator: { fallbacks: ["%locale%"] }
# ...