mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-06 07:27:17 +00:00
0bbe173d29a3d2a42f65bb1a22d42168a2cf54ed
This PR was merged into the 3.x branch. Discussion ---------- [String] Add singularize and pluralize filter This PR follows up this one in Symfony https://github.com/symfony/symfony/pull/57245. It adds 2 new filters `singularize` and `pluralize`. It uses the String component, especially `EnglishInflector` and `FrenchInflector`. Examples: ```php {{ 'person'|pluralize('en') }} // persons {{ 'person'|pluralize('en', false) }} // ['persons', 'people'] {{ 'personne'|pluralize('fr') }} // personnes {{ 'personne'|pluralize('fr', false) }} // ['personnes'] {{ 'persons'|singluarize('en') }} // person {{ 'people'|singluarize('en') }} // person {{ 'persons'|singluarize('en', false) }} // ['person'] {{ 'personnes'|singluarize('fr') }} // personne {{ 'personnes'|singluarize('fr', false) }} // ['personne'] {{ 'persona'|pluralize('it') }} // \InvalidArgumentException('Language "it" is not supported.') {{ 'persone'|singluarize('it') }} // \InvalidArgumentException('Language "it" is not supported.') ``` Commits -------8c969d40Tweak code and docscb392489feat(string-extra): Add singularize and pluralize filter
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://docs.blackfire.io/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%