Skip to content

3.1.0

Choose a tag to compare

@magicsunday magicsunday released this 06 Oct 11:26
· 9 commits to main since this release
3.1.0
fa31d8e

3.1.0 adds a shared test case that locks the structure of the translation catalogues a webtrees module ships. Nothing else changes, existing code keeps working.

New

  • Testing\AbstractCatalogueStructureTestCase is an abstract PHPUnit case. A module extends it in its own tests/ and implements languageDirectory(), the directory with one subdirectory per locale that holds messages.po and its compiled messages.mo.

    webtrees merges the compiled catalogue of a module over its own, so a plural entry with the wrong number of forms or an empty form damages the translation of the same text everywhere in the installation. The case guards against that:

    • the form count of every compiled plural entry against the plural rule class of the locale, never against the PO header
    • the slot count of the source catalogue, including entries the compiler drops
    • empty forms
    • the %s and %d placeholders, numbered ones included. Unnumbered placeholders keep their order, numbered ones may change position.
    • the compiled catalogue against its source
    • a complete Plural-Forms header line
    • a render of every plural entry for a range of numbers

    A subclass needs #[CoversNothing] when its phpunit.xml sets requireCoverageMetadata.

Notes for consumers

  • The class ships with the library but extends PHPUnit\Framework\TestCase, so it is only loaded when a module extends it. PHPUnit is a suggest, not a requirement.
  • The case sits in its own deptrac layer that depends on no other src/ code.
  • Modules that carry their own copy of these checks can replace it with a subclass that names the catalogue directory.