symfocode / twig-i18n
Twig internationalization tools for Symfony2
v0.2.3
2015-01-07 10:11 UTC
Requires
- php: >=5.3.3
- symfony/http-foundation: ~2.5
- twig/twig: ~1.12
README
Internationalization tools based on Symfony2 components and Twig.
Twig-i18n works with PHP 5.3.3 or later.
Features
- The LinkI18nExtension makes it easy to create locale links. Learn more.
<ul class="nav"> <li {{- active_link('home') }}> <a href="{{ path('home') }}">Home</a> </li> <li {{- active_link('about') }}> <a href="{{ path('about') }}">Page</a> </li> <li {{- active_link('contacts', 'last-nav-item') }}> <a href="{{ path('contacts') }}">Some page (default locale)</a> </li> </ul> <ul class="lang"> {% for locale, params in app.system_locales %} <li {{- active_locale(locale, params.flag) }}> <a href="{{ path(active_route(), {'_locale': locale}) }}" title="{{ params.name }}"> {{ params.abbr }} </a> </li> {% endfor %} </ul>
- The DateI18nExtension makes it easy to create custom date formats. Learn more.
<div>{{ datetime|localedate('date_time') }}</div> <div>{{ datetime|localedate('short_date') }}</div> <div>{{ datetime|localedate('medium_date') }}</div> <div>{{ datetime|locale_date('long_date') }}</div> <div>{{ datetime|locale_date('full_date') }}</div> <div>{{ datetime|locale_date('some_format') }}</div>
Installation
The recommended way to install Silex-i18n is through
composer. Just create a composer.json
file and
run the php composer.phar install
command to install it:
{ "require": { "symfocode/twig-i18n": "~0.2" } }
License
Twig-i18n is licensed under the MIT license.