A Twig Extension filter to format number into ordinal form (1st, 2nd, etc.).
With composer
composer require fvozar/twig-ordinal-number-filter
Basic usage is just put ordinal filter on your number.
{{ someNumber | ordinal }}
You can also provide another locale for internally used \NumberFormatter class
{{ someNumber | ordinal('sk') }}
For Symfony usage you'll want to add it as a service and tag it for Twig.
# app/config/services.yml
services:
twig.extension.ordinal:
class: Fvozar\Twig\OrdinalNumberExtension
tags:
- { name: twig.extension }