Because you have the locales specified as a parameter you can retrieve the parameter value depending on where you want it:
1. As service argument:
Pass the locales via constructor parameters by specifying in the service definition:
Service:
class SomeService {
private $locales;
public function __construct(array $locales)
{
$this->locales = $locales;
}
...
}
Service definition:
...\Service\SomeService:
arguments:
- '%app.locales%'
2. With the service container:
You can also retrieve parameters via the service container:
$locales = $this->container->getParameter('app.locales');
3. Pass locales to Twig
After getting the locales via above ways you can just pass them as variable just like normal Twig variables when rendering a template:
return $this->render('some.template.html.twig', [
'locales' => $locales,
]);
4. Set specific Twig parameters:
How to get config parameters in Symfony2 Twig Templates