Skip to content

Feature: Translate ValueObjects via TranslationConnectorInterface#75

Merged
mficzel merged 5 commits into2.0from
feature/translateValueObjects
Sep 29, 2025
Merged

Feature: Translate ValueObjects via TranslationConnectorInterface#75
mficzel merged 5 commits into2.0from
feature/translateValueObjects

Conversation

@mficzel
Copy link
Copy Markdown
Member

@mficzel mficzel commented Sep 25, 2025

This adds the TranslationConnectorInterface that allows to extract and reapply translatable fields from valueObjects.

/**
 * @template T of object
 */
interface TranslationConnectorInterface
{
    /**
     * @param T $object
     * @return array<non-empty-string, string>
     */
    public function extractTranslations(object $object): array;

    /**
     * @param T $object
     * @param array<non-empty-string, string> $translations
     * @return T
     */
    public function applyTranslations(object $object, array $translations): object;
}

The feature is configured via setting:

Sitegeist:
  LostInTranslation:  
    nodeTranslation:
   
      #
      # Translate all object properties that have a translationConnector configured
      # if this is set to false each property must be enabled via options.automaticTranslation
      #
      translateTypesWithConnectors: true

      #
      # Connectors to translate value object properties
      #
      # for each value object type a clas implementing the TranslationConnectorInterface
      # can be configured to extract and apply translations
      #
      translationConnectors:  
        Vendor\Site\Class => Vendor\Site\ClassConnector

@mficzel mficzel force-pushed the feature/translateValueObjects branch 3 times, most recently from 9ddbb74 to 689731f Compare September 25, 2025 14:56
@mficzel mficzel force-pushed the feature/translateValueObjects branch from 689731f to 97f2be5 Compare September 25, 2025 15:01
…anager for complex cases

This will allow to inject dependencies if needed.
@mficzel mficzel changed the title Feature: Translate value objects Feature: Translate ValueObjects via TranslationConnectorInterface Sep 25, 2025
@mficzel mficzel force-pushed the feature/translateValueObjects branch from bf91931 to a98f14e Compare September 25, 2025 16:59
@mficzel mficzel requested a review from mwuest September 29, 2025 15:11
@mficzel mficzel merged commit ad25460 into 2.0 Sep 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants