Intl support for Twig

Overview

Twig Intl Extension

This package is a Twig extension that provides the following:

You might also like...
Task for GrumPHP that adds CSS linting support with stylelint. An easy way to enforce convention and avoid errors in your styles

grumphp-stylelint-task Installation Stylelint is a static analysis tool for styles. A mighty, modern linter that helps you avoid errors and enforce co

PHPStan extension to support #[Readonly] constructor properties

icanhazstring/phpstan-readonly-property Support #[Readonly] promoted constructor properties for PHPStan. This library is used to have a full transitio

A GETTR.com client library written in PHP with Laravel support.
A GETTR.com client library written in PHP with Laravel support.

Gettr API Clinet PHP A GETTR.com client library written in PHP with Laravel support. This library uses unofficial publicly accessible API endpoints of

A non-intrusive support form that can be displayed on any page
A non-intrusive support form that can be displayed on any page

A non-intrusive support bubble that can be displayed on any page Using this package you can quickly add a chat bubble that opens a support form on any

Okex API Like the official document interface, Support for arbitrary extension.

It is recommended that you read the official document first Okex docs https://www.okex.com/docs/en Okex Simulation Test API https://www.okex.com/docs/

Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitweb, Cgit, Subversion, Mercurial and more

Source control integration plugin framework for MantisBT, including support for Github, Gitlab, Bitbucket, Gitweb, Cgit, Subversion, Mercurial and more

Versi dinamis dari spk fuzzy sebelumnya, kini support setting jumlah sub kriteria

spk-fuzzy-dynamic Versi dinamis dari spk fuzzy sebelumnya, kini support setting jumlah sub kriteria SPK-Pariwisata-Fuzzy Implementasi Fuzzy Tahani Pad

Support for PHP 8.1 enums in Doctrine.

Doctrine Native Enums This library provides first-class support to PHP Enums, introduced in PHP 8.1, within your Doctrine entities. Installation compo

Paddle.com API integration for Laravel with support for webhooks/events

Laravel Paddle This package provides an integration with Paddle.com for Laravel. Read the blogpost about the introduction of the package! Features Sup

Comments
  • Handle MissingResourceException

    Handle MissingResourceException

    When you want to get the language name of a language you can type:

    {{ inputLanguage | language_name }}
    

    But if inputLanguage is not a valid language, a MissingResourceException is thrown, blowing up the whole page.

    Since in Twig, there is no way to catch this exception, it becomes extremely hard to work with these helpers if you have no control over the input. There is also no way to first check if the language exists before invoking the filter.

    The same applies to all the other Intl:: calls that happen. They can all throw the same exception. I didn't change that yet, because I first want to know your opinion about this. If you agree, that it should fallback to the input, then I will change the rest too.

    opened by ruudk 2
  • Add test showing currency bug

    Add test showing currency bug

    This is just to show some weird behaviour that I have no idea how to fix it.

    What I've found so far is that the problem seems to occur when the currency symbol ¤ is involved in the text attributes:

    https://github.com/twigphp/intl-extra/blob/ae0757394e8fc86ee2d0a8398f5947e9ac7c27d5/src/IntlExtension.php#L411-L413

    When numberFormatterProto is created with en locale these are its properties before (in red) and after (in green) going through the IntlExtension:

    2,3c2,3
    <   locale: "en"
    <   pattern: "¤#,##0.0"
    ---
    >   locale: "en_US"
    >   pattern: "'¤'#,##0.0;'-¤'#,##0.0"
    18c18
    <     FORMAT_WIDTH: false
    ---
    >     FORMAT_WIDTH: 0
    

    In case of fr locale are these:

    2,3c2,3
    <   locale: "fr"
    <   pattern: "#,##0.0 ¤"
    ---
    >   locale: "en_US"
    >   pattern: "#,##0.0 '¤';'-'#,##0.0 '¤'"
    18c18
    <     FORMAT_WIDTH: false
    ---
    >     FORMAT_WIDTH: 0
    

    Looks like it escapes the symbol and does not change it to the local currency.

    And this is the PHPUnit output:

    Testing Twig\Extra\Intl\Tests\IntlExtensionTest
    FF                                                                  2 / 2 (100%)
    
    Time: 121 ms, Memory: 6.00 MB
    
    There were 2 failures:
    
    1) Twig\Extra\Intl\Tests\IntlExtensionTest::testFormatterProtoWithCurrency with data set #0 ('en', '€12.3')
    Failed asserting that two strings are identical.
    --- Expected
    +++ Actual
    @@ @@
    -'€12.3'
    +'¤12.3'
    
    /intl-extra/tests/IntlExtensionTest.php:37
    
    2) Twig\Extra\Intl\Tests\IntlExtensionTest::testFormatterProtoWithCurrency with data set #1 ('fr', '12,3 €')
    Failed asserting that two strings are identical.
    --- Expected
    +++ Actual
    @@ @@
    -'12,3 €'
    +'12,3 ¤'
    
    /intl-extra/tests/IntlExtensionTest.php:37
    
    FAILURES!
    Tests: 2, Assertions: 2, Failures: 2.
    
    opened by franmomu 0
  • `format_datetime` ignores date/time format with `IntlDateFormatter` prototype

    `format_datetime` ignores date/time format with `IntlDateFormatter` prototype

    I originally described this issue in https://github.com/twigphp/Twig/issues/3568#issuecomment-931382860 but have created this PR to keep the discussion focussed.

    opened by drjayvee 2
  • add ext-intl in require

    add ext-intl in require

    This is a necessary dependency.

    Otherwise, when upgrading symfony 5.0.* to 5.2.

    The inability to run composer require twig/intl-extra.

    P.s. Excuse my English, I'm learning Japanese.

    opened by demoneno4ec 0
Owner
Twig
Twig
Symfony Polyfill / Intl: Grapheme

This component provides a partial, native PHP implementation of the Grapheme functions from the Intl extension.

Symfony 1.3k Jan 6, 2023
A tool to automatically fix Twig Coding Standards issues

Twig CS Fixer Installation This standard can be installed with the Composer dependency manager. Add the coding standard as a dependency of your projec

Vincent Langlet 50 Jan 6, 2023
Manifest is a ProcessWire module that bridges between Twig and Webpack.

Manifest is a ProcessWire module that bridges between Twig and Webpack.

Rudy Affandi 4 Nov 12, 2022
Twig extensions for common navigation widgets for symfony.

Twig Navigation Extension This bundle provides a Twig extensions for common navigation widgets. Installation composer require m2mtech/twig-navigation-

Martin Mandl 1 Feb 23, 2022
Pattern Lab Standard Edition for Twig

Pattern Lab Standard Edition for Twig The Standard Edition for Twig gives developers and designers a clean and stable base from which to develop a Twi

Pattern Lab 102 Oct 24, 2022
A custom twig extension to truncate text while preserving HTML tags.

TwigTruncateExtension A custom twig extension to truncate text while preserving HTML tags. Installation Add the library to your app's composer.json:

dzango 12 Oct 30, 2019
Benchmark of Elefant's template engine against Twig templates

Template Benchmark This is a simple benchmark to test the memory usage and speed of rendering templates using Elefant's Template engine, Twig, and Sma

John de Plume 9 Jun 28, 2016
Michael Pratt 307 Dec 23, 2022
The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

The Assure Alliance support website. This website is based on Questions2Answers and is a forum for support using Biblical Tools

United Bible Societies Institute for Computer Assisted Publishing 3 Jul 29, 2022
PHP library providing retry functionality with multiple backoff strategies and jitter support

PHP Backoff Easily wrap your code with retry functionality. This library provides: 4 backoff strategies (plus the ability to use your own) Optional ji

Signature Tech Studio 145 Dec 21, 2022