eddiejaoude/eddie-jaoude-symfony-translation-twig-collection-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Symfony Translation Bundle for Twig Extension to handle collection

2.6.0 2015-01-11 10:32 UTC

This package is not auto-updated.

Last update: 2024-10-12 16:20:42 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

DashboardHub Badge

Symfony Translation Twig Collection Bundle

Symfony Translation Bundle for Twig Extension to handle collection

Installation

  1. Composer
   "require": {
       "eddiejaoude/eddie-jaoude-symfony-translation-twig-collection-bundle": "dev-master"
   }
  1. Run update
php composer.phar update
  1. Add to AppKernel
   $bundles = array(
   // ...
   new EddieJaoude\Bundle\SymfonyTranslationTwigCollectionBundle\EddieJaoudeSymfonyTranslationTwigCollectionBundle(),
   // ...
   )

Usage

Translation file (eg. messages.en.yml)

termsAndConditions:
  title: Terms and Conditions
  paragraph:
    - Terms Information 1
    - Terms Information 2
    - Terms Information 3
    - Terms Information 4
    ...

Twig template (eg. index.html.twig)

{% for i in range(0,'termsAndConditions.paragraph'|translationLength) -%}
    <p>{{('termsAndConditions.paragraph.'~i)|trans}}</p>
{%- endfor %}

Output

Terms Information 1
Terms Information 2
Terms Information 3
Terms Information 4

Credits

Inspired by acontell http://stackoverflow.com/questions/27868921/symfony2-translation-yaml-array-and-twig-loop