Migration

Upgrade notes for breaking and notable changes between versions.

Migrating to v3.17 (KirbyText Removal)

JohannSchopplich\ContentTranslator\KirbyText::translateText() is removed. Migrate to Translator::translateText() – the diff under v3.11 shows the change.

Migrating to v3.16 (Nested Field Keys)

TranslationUnit::$fieldKey now leads with the container for a field inside a structure, object, blocks, or layout field: body.text where v3.15 reported text. Top-level fields are unchanged. A translate:warning handler that matches nested field names needs the new form.

Migrating to v3.14 (Rejection 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 rejected 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:

  • johannschopplich.content-translator.translateFn – migrate to 'strategy' => $closure. Signature is identical.
  • JohannSchopplich\ContentTranslator\KirbyText::translateText() – migrate to Translator::translateText(). Removed in v3.17.

translateFn → strategy

site/config/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');

Translator::translateText() routes through the configured strategy but translates the string as plain text – KirbyTags in it are not protected. Text with KirbyTags keeps them intact when it is translated as a textarea field through translateContent(), which applies the kirbyTags option.

For the new architecture, see PHP Classes → Strategies.