Skip to content

v2.1.0 — Locale Variant DX Improvements

Choose a tag to compare

@CreativeNative CreativeNative released this 04 Mar 10:39
· 113 commits to master since this release

What's New

Three quality-of-life improvements that reduce consumer boilerplate for locale variant workflows.

Auto-reset generated IDs (#7)

TranslatableEntityHandler now automatically resets properties with #[ORM\Id] + #[ORM\GeneratedValue] to null on cloned translations. No more reflection boilerplate in consumer code.

translateAndPersist() and getOrTranslate() (#8)

Two new convenience methods on EntityTranslatorInterface:

  • translateAndPersist() — translate + persist in one call
  • getOrTranslate() — returns existing translation or creates + persists a new one

TranslatableRepositoryTrait (#9)

A new trait for Doctrine entity repositories with batch locale variant queries:

  • findAllLocaleVariants(Tuuid) — all locale variants keyed by locale
  • findAllLocaleVariantsBatch(list<Tuuid>) — batch lookup grouped by tuuid then locale

Both methods temporarily disable the locale filter to query across all locales.

Stats

  • 422 tests, 2794 assertions
  • 100% code coverage (1094/1094 lines)
  • PHPStan level max: 0 errors