2017 © Pedro Peláez
 

library translatableroutepath-bundle

JpnForPhp Symfony2 bundle integration

image

albertofem/translatableroutepath-bundle

JpnForPhp Symfony2 bundle integration

  • Sunday, November 30, 2014
  • by albertofem
  • Repository
  • 0 Watchers
  • 3 Stars
  • 278 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

TranslatableRoutePathBundle

build status Scrutinizer Code Quality, (*1)

Allows using translations in routes paths:, (*2)

/**
 * @Route("/[my.translatable.key]/route/{param}", options={"translatable"=true})
 */
public function myAction()
{
}

If my.transatable.key is defined in English as: my_translatable_route, this will produce a route:, (*3)

/my_translatable_route/route/whatever_param

Installation

Require it in composer:, (*4)

composer require albertofem/translatableroutepath-bundle dev-master

Install it:, (*5)

composer update albertofem/translatableroutepath-bundle

Add it to your bundles:, (*6)

$bundles = array(
    ...,
    new \AFM\Bundle\TranslatableRoutePathBundle\AFMTranslatableRoutePathBundle()
);

Additionally, you can use this bundle with JMSI18nRoutingBundle in which case you will need to register it before this one:, (*7)

$bundles = array(
    ...
    new \JMS\I18nRoutingBundle\JMSI18nRoutingBundle(),
    new \AFM\Bundle\TranslatableRoutePathBundle\AFMTranslatableRoutePathBundle()
);

If you need to run the tests:, (*8)

./vendor/bin/phpunit

Usage

You need to add the option to your route to be translatable:, (*9)

/**
 * @Route("/[my.translatable.key]/route/{param}", options={"translatable"=true})
 */
public function myAction()
{
}

Using YAML:, (*10)

my_translatable_route:
    path: /[my.translatable.key]/route/{param}
    options: { translatable: true }

Use the syntax [...] to referer to translations in your routes paths. You can use this syntax in annotations/yaml/PHP indistintively., (*11)

Integration with JMSI18nRoutingBundle

If your are using this great bundle, routes will be automatically translated to all the locales set in the configuration., (*12)

Integration with Symfony core Router

When using Symfony core router, all routes are translated into the default locale. If you need a Route to be translated in another language, you must specify the _locale default parameter:, (*13)

my_translatable_route:
    path: /[my.translatable.key]/route/{param}
    options: { translatable: true }
    defaults: { _locale: en } # this route will translated in English

TODO

  • Support parameters for translations (domains, etc.)
  • Support transChoice

The Versions

30/11 2014

dev-master

9999999-dev http://albertofem.com

JpnForPhp Symfony2 bundle integration

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle route symfony translatable path