2017 © Pedro Peláez
 

library twig-locale-name-extension

Twig locale name filter extension for twig

image

alaczi/twig-locale-name-extension

Twig locale name filter extension for twig

  • Thursday, July 21, 2016
  • by alaczi
  • Repository
  • 0 Watchers
  • 1 Stars
  • 2,245 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

Usage

This twig extension is to write the human readable names of the 2 or 5 letter locale codes (eg: en or en_GB), (*1)

Ideal to use with the language picker as you can pass the locale as second parameter to display the locale name on that language, (*2)

Require as dependency

    composer require alaczi/twig-locale-name-extension

Register the extension

PHP

    $filter = new \alaczi\Twig\Extension\LocaleNameExtension();
    $twig = new Twig_Environment($loader);
    $twig->addFilter($filter);

Symfony 2

services:
    alaczi.twig.country_extension:
        class: alaczi\Twig\Extension\LocaleNameExtension
        tags:
            - { name: twig.extension }

Silex

    $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
        /** @var \Twig_Environment $twig */
        $twig->addExtension(new \alaczi\Twig\Extension\LocaleNameExtension())
        return $twig;
    }));

Usage in twig

Using the current locale:, (*3)

    {{ locale|locale_name }}

Using an other locale (eg: for language pickers), (*4)

    {{ locale|locale_name(locale) }}

The Versions

21/07 2016

dev-master

9999999-dev http://github.com/alaczi/twig-locale-name-extension

Twig locale name filter extension for twig

  Sources   Download

MIT

The Requires

 

by Andras Laczi

twig extension filter locale

21/07 2016

v1.0.1

1.0.1.0 http://github.com/alaczi/twig-locale-name-extension

Twig locale name filter extension for twig

  Sources   Download

MIT

The Requires

 

by Andras Laczi

twig extension filter locale

29/02 2016

v1.0.0

1.0.0.0 http://github.com/alaczi/twig-locale-name-extension

Twig locale name filter extension for twig

  Sources   Download

MIT

The Requires

 

by Andras Laczi

twig extension filter locale