Skip to content

Conversation

@vlakoff
Copy link
Contributor

@vlakoff vlakoff commented Nov 27, 2025

This reverts #100 which replaced %s with %.3F.

As I elaborated in this comment, PHP ≥ 8.0 formatting is locale-independent, so %.3F is no longer necessary and introduced trailing zeroes in scale/translate attributes.

This reverts Bacon#100 which replaced %s with %.3F.

PHP ≥ 8.0 formatting is locale-independent, so %.3F is no longer necessary
and introduced trailing zeroes in scale/translate attributes.
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.81%. Comparing base (c2fe9b3) to head (044d331).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #218   +/-   ##
=========================================
  Coverage     70.81%   70.81%           
  Complexity      994      994           
=========================================
  Files            49       49           
  Lines          3169     3169           
=========================================
  Hits           2244     2244           
  Misses          925      925           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DASPRiD
Copy link
Member

DASPRiD commented Nov 27, 2025

Mind adding a test for e.g. the SVG renderer which does calls setlocale() to verify this; just in case PHP decides to break this again :)

@vlakoff
Copy link
Contributor Author

vlakoff commented Nov 27, 2025

Mmm… as always with writing tests, I struggle to find motivation for this one.

Code snippets:

Method A:

public function testSomethingWithLocale()
{
    $originalLocale = setlocale(LC_ALL, 0);

    try {
        $locale = (PHP_OS_FAMILY === 'Windows') ? 'French_France.1252' : 'fr_FR.UTF-8';
        $result = setlocale(LC_ALL, $locale);
        if ($result === false) {
            $this->markTestSkipped("Locale {$locale} is not available on this system.");
        }

        // ... run your test code here ...

    } finally {
        // always executed, even if test fails or throws
        setlocale(LC_ALL, $originalLocale);
    }
}

Method B:

class LocaleTest extends TestCase
{
    private $originalLocale;

    #[Before]
    public function switchLocale()
    {
        $this->originalLocale = setlocale(LC_ALL, 0);

        $locale = (PHP_OS_FAMILY === 'Windows') ? 'French_France.1252' : 'fr_FR.UTF-8';
        $result = setlocale(LC_ALL, $locale);
        if ($result === false) {
            $this->markTestSkipped("Locale {$locale} is not available on this system.");
        }
    }

    #[After]
    public function restoreLocale()
    {
        setlocale(LC_ALL, $this->originalLocale);
    }

    public function testLocalizedBehavior()
    {
        // ... test code that depends on locale ...
    }
}

edit: I've added a check to ensure that setlocale(LC_ALL, 'fr_FR.UTF-8') executes successfully; otherwise, the test is skipped.

edit 2: fr_FR.UTF-8 wasn't working on Windows, so I added the Windows-specific French_France.1252 for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants