anezi/locale-extension

Locale Extensions for Twig

1.2.1 2020-12-13 21:20 UTC

This package is auto-updated.

Last update: 2024-11-14 06:07:13 UTC


README

Installation

The extension is installable via composer:

composer require anezi/locale-extension

Symfony service

services:
    anezi_twig.locale_extension:
        class: Anezi\Locale\Twig\Extension\LocaleExtension
        public:    false
        arguments: ["%managed_locales%"]
        tags:
            - { name: twig.extension }

Functions

Get locales

{% for locale in locales() %}{{ locale }} - {% endfor %}

shows:

ar - en - fr -

Filters

Get country name

{{ "be"|country_name }}

shows:

Belgium

Get locale name

{{ "fr_BE"|locale_name }}

shows:

French (Belgium)

Get locale name in that locale

{{ "fr_BE"|origin_locale_name }}

shows:

français (Belgique)

Get locale short name

{{ "fr_BE"|locale_short_name }}

shows:

fr

Get html direction

{{ "ar"|html_dir }}

shows:

rtl