wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

Add support for pretty-printing PHP files in wp i18n make-php command #396

Open sovetski opened 3 months ago

sovetski commented 3 months ago

It should resolve this issue: https://github.com/wp-cli/i18n-command/issues/395

ernilambar commented 3 months ago

@sovetski FYI: You can run Behat test locally easily using commands like:

WP_CLI_TEST_DBTYPE=sqlite composer behat features/makephp.feature:263

This will run behat test of given file and 263 is the line number of your new Scenario. This will be helpful for quick test in local environment. With using sqlite, you don't have to face hassle for MySQL setup.

sovetski commented 3 months ago

@sovetski FYI: You can run Behat test locally easily using commands like:

WP_CLI_TEST_DBTYPE=sqlite composer behat features/makephp.feature:263

This will run behat test of given file and 263 is the line number of your new Scenario. This will be helpful for quick test in local environment. With using sqlite, you don't have to face hassle for MySQL setup.

Thank you, it helped a lot, now the test pass successfully

image

sovetski commented 3 months ago

I don't understand. The command WP_CLI_TEST_DBTYPE=sqlite composer behat features/makephp.feature:263 was working as well, I just removed 1 space and adapted my scenario, I have this error without any explanation:

image

When I add -vvv it returns an unreadable PHP exception. But the returned error output matches the scenario's expected output, so very weird...

swissspidy commented 3 months ago

When I add -vvv it returns an unreadable PHP exception. But the returned error output matches the scenario's expected output, so very weird...

It sounds like it doesn't match exactly.

When I manually run the wp i18n command in my terminal, I get this output with lots of indentation (8 spaces):

<?php
return [
        'domain' => 'foo-plugin',
        'plural-forms' => 'nplurals=2; plural=(n != 1);',
        'language' => 'de_DE',
        'project-id-version' => 'Foo Plugin',
        'pot-creation-date' => '2018-05-02T22:06:24+00:00',
        'po-revision-date' => '2018-05-02T22:06:24+00:00',
        'messages' => [
                'Foo Plugin' => 'Foo Plugin',
                'Hello' => 'Hallo',
                'You have %d new message' => 'Du hast %d neue Nachricht' . "\0" . 'Du hast %d neue Nachrichten',
        ],
];