2017 © Pedro Peláez
 

symfony-bundle eb-translationbundle

EBTranslationBundle

image

proprietes-privees/eb-translationbundle

EBTranslationBundle

  • Tuesday, January 9, 2018
  • by proprietes-privees
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

EBTranslationBundle

This bundle helps me deal with links in my templates., (*1)

Default configuration

# app/config/config.yml

eb_translation:
  # domain where translations are stored
  domain: messages
  # default locale
  locale: '%locale%'
  # add route name as class when generating a link
  use_route_as_class: false
  # replace underscores by points in route names to
  # find its translation : home_index => home.index
  # create array structures in Yaml
  replace_underscore: true
  # link translations prefix
  prefix: 'page.'
  # wether we have to track selected links by adding
  # a class when the route is the same as the current
  # route (the class to add, or null)
  track_selected_links: 'active'

Translation example base on the default configuration

# messages.fr.yml
page:
  home:
    name: 'Home page name'
    title: 'Home page title'
    description: 'Home page description'
````

## Controller

```php
// SomeController.php

/** @var EB\TranslationBundle\Translation $translation */
$translation = $this->get('eb_translation');

// <a href="/" title="Home page title">Home page name</a>
$translation->link('home');

// <a href="/page-1" title="Home page title">Home page name</a>
$translation->link('home',{'page':1});

// <a href="/" title="Home page title">something</a>
$translation->link('home',{},{'name':'something'});

// <a href="/" title="something">Home page name</a>
$translation->link('home',{},{'title':'something'});

// <a href="/" title="Home page title" class="something">Home page name</a>
$translation->link('home',{},{'class':'something'});

// Home page name
$translation->name('home');

// Home page title
$translation->title('home');

// Home page description
$translation->description('home');
````

## Twig

```jinja
{# SomeTemplate.html.twig #}

{# @return '<a href="/" title="Home page title">Home page name</a>' #}
{{ link('home') }}

{# @return '<a href="/page-1" title="Home page title">Home page name</a>' #}
{{ link('home',{'page':1}) }}

{# @return '<a href="/" title="Home page title">something</a>' #}
{{ link('home',{},{'name':'something'}) }}

{# @return '<a href="/" title="something">Home page name</a>' #}
{{ link('home',{},{'title':'something'}) }}

{# @return '<a href="/" title="Home page title" class="something">Home page name</a>' #}
{{ link('home',{},{'class':'something'}) }}

{# @return 'Home page name' #}
{{ name('home') }}

{# @return 'Home page title' #}
{{ title('home') }}

{# @return 'Home page description' #}
{{ description('home') }}

The Versions

09/01 2018

dev-master

9999999-dev https://github.com/proprietes-privees/EBTranslationBundle.git

EBTranslationBundle

  Sources   Download

MIT

The Requires

  • php >=5.5

 

by Emmanuel BALLERY

26/01 2016

0.0.4

0.0.4.0 https://github.com/emmanuelballery/EBTranslationBundle.git

EBTranslationBundle

  Sources   Download

MIT

The Requires

 

by Emmanuel BALLERY

22/01 2016

0.0.3

0.0.3.0 https://github.com/emmanuelballery/EBTranslationBundle.git

EBTranslationBundle

  Sources   Download

MIT

The Requires

 

by Emmanuel BALLERY

15/01 2015

0.0.2

0.0.2.0 https://github.com/emmanuelballery/EBTranslationBundle.git

EBTranslationBundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Emmanuel BALLERY

28/09 2014

0.0.1

0.0.1.0 https://github.com/emmanuelballery/EBTranslationBundle.git

EBTranslationBundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Emmanuel BALLERY