Skip to content

Commit 8b97e3f

Browse files
authored
Merge pull request #11 from mlocati-forks/arraygenerator-empty
Fix ArrayGenerator::generateString() with includeEmpty === true
2 parents 8ae0ac7 + b6bced0 commit 8b97e3f

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎.github/workflows/test.yaml‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,28 @@ jobs:
1414
strategy:
1515
matrix:
1616
php:
17-
- 7.2
18-
- 7.3
19-
- 7.4
20-
- 8.0
21-
- 8.1
22-
- 8.2
23-
- 8.3
24-
- 8.4
17+
- "7.2"
18+
- "7.3"
19+
- "7.4"
20+
- "8.0"
21+
- "8.1"
22+
- "8.2"
23+
- "8.3"
24+
- "8.4"
25+
- "8.5"
2526
fail-fast: false
2627

2728
steps:
2829
- name: Checkout
29-
uses: actions/checkout@v4
30+
uses: actions/checkout@v6
3031

3132
- name: Install PHP
3233
uses: shivammathur/setup-php@v2
3334
with:
3435
php-version: ${{ matrix.php }}
3536

3637
- name: Cache PHP dependencies
37-
uses: actions/cache@v4
38+
uses: actions/cache@v5
3839
with:
3940
path: vendor
4041
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}

‎src/Generator/ArrayGenerator.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ public function generateArray(Translations $translations): array
7676
if (self::hasPluralTranslations($translation)) {
7777
$messages[$context][$original] = $translation->getPluralTranslations($pluralSize);
7878
array_unshift($messages[$context][$original], $translation->getTranslation());
79+
} elseif ($pluralSize !== null && $pluralSize > 1 && (string) $translation->getPlural() !== '') {
80+
$messages[$context][$original] = array_fill(0, $pluralSize, '');
7981
} else {
80-
$messages[$context][$original] = $translation->getTranslation();
82+
$messages[$context][$original] = (string) $translation->getTranslation();
8183
}
8284
}
8385

‎tests/ArrayGeneratorTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testArrayGeneratorWithEmptyTranslations()
6666
'messages' => [
6767
'' => [
6868
'Empty translation included' => '',
69-
'Inexistent translation included' => null,
69+
'Inexistent translation included' => '',
7070
],
7171
],
7272
];

0 commit comments

Comments
 (0)