bug #30951 Handle case where no translations were found (greg0ire)

This PR was merged into the 3.4 branch.

Discussion
----------

Handle case where no translations were found

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Right now, the program emits a warning when trying to use max() on an
empty array.

Commits
-------

79b1fb8333 Handle case where no translations were found
This commit is contained in:
Fabien Potencier 2019-04-07 10:36:55 +02:00
commit 3d6f15251a
1 changed files with 5 additions and 0 deletions

View File

@ -159,6 +159,11 @@ function printTitle($title)
function printTable($translations, $verboseOutput)
{
if (0 === count($translations)) {
echo 'No translations found';
return;
}
$longestLocaleNameLength = max(array_map('strlen', array_keys($translations)));
foreach ($translations as $locale => $translation) {