eddiejaoude / eddie-jaoude-symfony-translation-twig-collection-bundle
Symfony Translation Bundle for Twig Extension to handle collection
Installs: 1 318
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 2
Forks: 5
Open Issues: 0
Requires
- php: >=5.5
- symfony/translation: *
- symfony/twig-bundle: *
Requires (Dev)
- henrikbjorn/phpspec-code-coverage: ~0.2
- phpspec/phpspec: ~2.0
This package is not auto-updated.
Last update: 2024-10-12 16:20:42 UTC
README
Symfony Translation Twig Collection Bundle
Symfony Translation Bundle for Twig Extension to handle collection
Installation
- Composer
"require": {
"eddiejaoude/eddie-jaoude-symfony-translation-twig-collection-bundle": "dev-master"
}
- Run update
php composer.phar update
- 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