Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

Previous releases are documented in [github releases](https://github.com/oscarotero/Gettext/releases)

## [Unreleased]
### Changed
- `MoGenerator` writes the header entry by default, so `.mo` files keep `Plural-Forms`. Use `includeHeaders(false)` to leave it out.

## [5.7.4] - 2026-11-20
### Fixed
- Add PHPStan level 5 - [#304]
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/MoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class MoGenerator extends Generator
{
private $includeHeaders = false;
private $includeHeaders = true;

public function includeHeaders(bool $includeHeaders = true): self
{
Expand Down
17 changes: 17 additions & 0 deletions tests/MoGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ public function testMoGenerator(): void
$this->assertCount(5, $result->getHeaders());
}

public function testPluralFormsAreWrittenByDefault(): void
{
$translations = Translations::create();
$translations->setLanguage('ru');
$translation = Translation::create(null, '%d file');
$translation->setPlural('%d files');
$translation->translate('%d файл');
$translation->translatePlural('%d файла', '%d файлов');
$translations->add($translation);

$mo = (new MoGenerator())->generateString($translations);
$result = (new MoLoader())->loadString($mo);

$this->assertSame($translations->getHeaders()->getPluralForm(), $result->getHeaders()->getPluralForm());
$this->assertSame(['%d файла', '%d файлов'], $result->find(null, '%d file')->getPluralTranslations());
}

public function testZeroStrings(): void
{
$translations = Translations::create();
Expand Down
Loading