Twig
Twig copied to clipboard
List languages, countries, locales, currencies, timezones
I think it would be interesting to be able to list with Twig functions the languages, countries, locales, currencies, timezones
For instance, for languages, we will reuse:
$languages = Languages::getNames();
// ('languageCode' => 'languageName')
// => ['ab' => 'Abkhazian', 'ace' => 'Achinese', ...]
Hi,
The filters are already available through https://github.com/twigphp/intl-extra , for example:
countries: https://twig.symfony.com/doc/3.x/filters/country_name.html locales: https://twig.symfony.com/doc/3.x/filters/locale_name.html currencies: https://twig.symfony.com/doc/3.x/filters/currency_name.html
If you need a list of values that you can than use in the filters I would suggest looking at: https://symfony.com/doc/current/components/intl.html#country-names and than insert these values in your templates.
So I think it is a good idea to have these type of "common" or "general" data available through FOSS, but it is already there :) It is just not here in the core of Twig. You will have to pick the packages you like yourself and than add those together.
I just created a PR.
Closing as there is an associated PR.