Download the PHP package besimple/i18n-routing-bundle without Composer

On this page you can find all versions of the php package besimple/i18n-routing-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package i18n-routing-bundle

I18nRoutingBundle, generate your I18N Routes for Symfony2

If you have a website multilingual, this bundle avoids of copy paste your routes for different languages. Additionally it allows to translate given routing parameters between languages in Router#match and UrlGenerator#generate using either a Symfony Translator or a Doctrine DBAL (+Cache) based backend.

Latest Version on Packagist Build Status Total Downloads

Information

When you create an I18N route and you go on it with your browser, the locale will be updated.

Installation

Update your configuration

Create your routing

To define internationalized routes in XML or YAML, you need to import the routing file by using the be_simple_i18n type:

You can optionally specify a prefix or translated prefixes as shown above.

Yaml routing file

XML routing file

Note that the XML file uses a different namespace than when using the core loader: http://besim.pl/schema/i18n_routing.

PHP routing file

Controller annotations

Annotation loading is only supported for Symfony 2.5 and greater and needs to be enabled as followed.

You can insert classic route in your routing

Yaml routing file

XML routing file

PHP routing file

Advanced locale support

By default this bundle allows any locale to be used and there is no check if a locale is missing for a specific route. This is great but sometimes you may wish to be strict, let take a look at the following configuration:

The locales.supported specifies which locales are supported.

The locales.filter option is responsible for filtering out any unknown locales so only routes for 'en' and 'nl' are available.

The locales.strict option when set to true is responsible for throwing a exception when a i18n route is found where the locale is unknown or where a locale is missing. This option can also be set to null to disable locale is missing for a route exception and false to disable exceptions.

Route naming

By default all routes that are imported are named '.' but sometimes you may want to change this behaviour. To do this you can specify a route name inflector service in your configuration as followed.

The service must implement the BeSimple\I18nRoutingBundle\Routing\RouteGenerator\NameInflector\RouteNameInflectorInterface interface.

There are currently 2 inflectors available by default be_simple_i18n_routing.route_name_inflector.default_postfix.

Default postfix inflector

The default postfix inflector changed the behaviour of to only add a locale postfix when the locale is not the default locale. A example configuration is as followed.

Generate a route in your templates

Specify a locale

Twig

{{ path('homepage.en') }}
{{ path('homepage', { 'locale': 'en' }) }}
{{ path('homepage.fr') }}
{{ path('homepage', { 'locale': 'fr' }) }}
{{ path('homepage.de') }}
{{ path('homepage', { 'locale': 'de' }) }}

PHP

Use current locale of user

Twig

{{ path('homepage') }}

PHP

Translating the route attributes

If the static parts of your routes are translated you get to the point really fast when dynamic parts such as product slugs, category names or other dynamic routing parameters should be translated. The bundle provides 2 implementations.

After configuring the backend you want to use (see below for each one), you can define a to be translated attribute in your route defaults:

The same goes with generating routes, now backwards:

{{ path("product_view", {"slug": product.slug, "translate": "slug"}) }}
{{ path("product_view2", {"slug": product.slug, "translate": ["slug", "category]}) }}

The reverse translation is only necessary if you have the "original" values in your templates. If you have access to the localized value of the current locale then you can just pass this and do not hint to translate it with the "translate" key.

Doctrine DBAL Backend

Configure the use of the DBAL backend

The Doctrine Backend has the following table structure:

Lookups are made through the combination of route name, locale and attribute of the route to be translated.

Every lookup is cached in a Doctrine\Common\Cache\Cache instance that you should configure to be APC, Memcache or Xcache for performance reasons.

If you are using Doctrine it automatically registers a listener for SchemaTool to create the routing_translations table for your database backend, you only have to call:

./app/console doctrine:schema:update --dump-sql
./app/console doctrine:schema:update --force

Translator backend

This implementation uses the Symfony2 translator to translate the attributes. The translation domain will be created using the pattern <route name>_<attribute name>

Custom backend

If you want to use a different implementation, simply create a service implementing BeSimple\I18nRoutingBundle\Routing\Translator\AttributeTranslatorInterface.

License

This bundle is under the MIT License (MIT). Please see License File for more information.


All versions of i18n-routing-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
symfony/routing Version ~2.3 || ~3.0
symfony/config Version ~2.3 || ~3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package besimple/i18n-routing-bundle contains the following files

Loading the files please wait ....