Skip to content

FEATURE: Add glossary management #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

lorenzulrich
Copy link
Contributor

This code is extracted from https://github.com/robert-heinig/Sitegeist.LostInTranslation/tree/feature/glossaries. Since this branch diverged heavily from the original package, I extracted all relevant changes to this branch.

This is not meant from merging as code style-wise the feature is not really in line with the rest of LostInTranslation. However, I'm pushing this as a base for discussion if we should bring this to a state that is mergeable.

This can be configured as follows:

Sitegeist:
  LostInTranslation:
    DeepLApi:
      glossary:
        backendModule:
          sortByLanguage: 'DE'
        languagePairs:
          -
            source: 'DE'
            target: 'EN'

This allows adding a glossary when DE is translated to EN. It relies on the deeplLanguage being set in the CR dimension configuration, e.g.:

Neos:
  ContentRepository:
    contentDimensions:
      language:
        label: 'Sprache'
        icon: icon-globe-europe
        default: de_CH
        defaultPreset: de_CH
        presets:
          de_CH:
            label: 'Deutsch'
            values:
              - de_CH
            uriSegment: ''
            options:
              deeplLanguage: 'DE'
          en_GB:
            label: 'English'
            values:
              - en_GB
            uriSegment: 'en'
            options:
              deeplLanguage: 'EN'
              translationStrategy: 'once'

Please be aware of the following:

  • The DeepL glossary API does not allow editing a glossary item (see here). That means that every time the glossary is changed, a new glossary must be pushed to DeepL and the old one deleted. Therefore, you need to execute ./flow flow glossary:sync to set up and sync the glossary (also when installing it).
  • The DeepL glossary apparently is not just a "search & replace" which will lead to unexpected results. Without enough text/context, it is possible that terms are not replaced or not replaced properly. I don't have more insight how it actually works, but found a mention of it here and have experienced the behaviour myself.

Resolves: #5
cc @robert-heinig

@lorenzulrich
Copy link
Contributor Author

@mficzel What is your general opinion on this PR? Should this go to a separate package extending LostInTranslation or would you be willing/interested to include it?

@mficzel
Copy link
Member

mficzel commented Feb 11, 2025

Did not really look into it as it says it is not Really meant to be merged. At least that is how I understood it.

@mficzel
Copy link
Member

mficzel commented Feb 11, 2025

In general I would like to have glossaries in lost in translation. Will take deeper look the next days

@lorenzulrich
Copy link
Contributor Author

Did not really look into it as it says it is not Really meant to be merged. At least that is how I understood it.

From a functional POV, it is ready and we have been using it in production for 1/2 year+.

There are some ToDos left in the code that need to be cleanup before merging. Depending on your deeper look, I'd be willing to update the code.

@mficzel
Copy link
Member

mficzel commented Feb 13, 2025

I agree to the code, it would be really cool to finally have glossay support in here. So feel free to fix the remaining issues.

You can ping me via Slack for faster feedback. Otherwise it may take while until i notice movement here.

Thanks a lot for your help, it is greatly appreciated.

@lorenzulrich lorenzulrich force-pushed the feature/glossary branch 3 times, most recently from 5a95cd0 to cad407a Compare February 13, 2025 20:04
protected string $authenticationKey;

public function __construct(
protected readonly LoggerInterface $logger,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mficzel PHPUnit is not happy here:

Error: Cannot initialize readonly property Sitegeist\LostInTranslation\Infrastructure\DeepL\DeepLTranslationService::$serverRequestFactory from scope Mock_AccessibleTestProxyf8c5d1ca5b11a34fe92f72f4fde95814_9b50f72f

How can this be resolved?

@lorenzulrich lorenzulrich force-pushed the feature/glossary branch 2 times, most recently from 4fbcfeb to a9828f5 Compare February 13, 2025 23:26
@lorenzulrich
Copy link
Contributor Author

@mficzel Apart from the failing build, this is now ready for a final review. Most changes I added are related to documentation and configuration.

@lorenzulrich lorenzulrich changed the title Draft: FEATURE: Add glossary management FEATURE: Add glossary management Feb 13, 2025
@mficzel
Copy link
Member

mficzel commented Feb 21, 2025

@lorenzulrich after working on this for a bit i decided to try doing it a little more simple. See #52 for what i ended up with.

It would be great if you could test this and give feedback wether it works for you aswell.

@mficzel
Copy link
Member

mficzel commented Jul 4, 2025

Was implemented here instead #63 thanks a lot for the inspiration to finally give it a shot

@mficzel mficzel closed this Jul 4, 2025
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.

FEATURE: Support glossaries
2 participants