Migration

Upgrade notes for breaking and notable changes – strategy interface, view-button defaults, HTML tag handling.

Migrating to v3.14 (Drop Reasons)

The reasons the translate:warning hook reports were renamed. A handler matching the old strings stops matching.

BeforeAfter
placeholder count mismatchplaceholder mismatch
empty or non-string translationempty translation, non-string translation

missing translation is new. A strategy returning fewer entries than it was given units used to be dropped silently.

For custom strategies, an empty string is now a failed unit rather than a translation, so the field keeps its source text instead of being blanked.

Migrating to v3.11 (Strategy Refactor)

v3.11 introduces a typed Strategy interface and a unified strategy config option. No breaking changes – existing code keeps working unchanged. Two deprecations to watch for v4:

  • johannschopplich.content-translator.translateFn – migrate to 'strategy' => $closure. Signature is identical.
  • JohannSchopplich\ContentTranslator\KirbyText::translateText() – migrate to Translator::translateText(). Same routing, same result.

translateFnstrategy

config.php
 return [
     'johannschopplich.content-translator' => [
-        'translateFn' => function (string $text, string $target, ?string $source) { /* … */ },
+        'strategy' => function (string $text, string $target, ?string $source) { /* … */ },
     ],
 ];

When both keys are set, strategy wins.

KirbyText::translateText()Translator::translateText()

-use JohannSchopplich\ContentTranslator\KirbyText;
-$translated = KirbyText::translateText($text, 'de', 'en', $kirbyTags);
+use JohannSchopplich\ContentTranslator\Translator;
+$translated = Translator::translateText($text, 'de', 'en');

The new pipeline routes through the configured strategy and handles KirbyTags structurally without per-call configuration.

For the new architecture, see PHP Classes → Strategies.