DO NOT MERGE: AI translate prototype #52
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
A quick implementation, that showcases the translate API core architecture and a provider external module. In this PR:
@apostrophecms/translation
represents a core module, integration point for AI translation providers (external module).deepl-provider
represents an external AI translation provider that integrates with the core translation API@apostrophecms/doc-type
enhances the core with the required event for page localization (should be core change)@apostrophecms/module
adds the public registration handler for providersdefault-page
adds debug field type to demonstrate what meta information will be available to the admin UIWhat are the specific steps to test this change?
npm install
.env
file in the project root and addDEEPL_API_SECRET=xxx
wherexxx
is the API secret as seen in your DeepL accountnpm run dev
)What happens?
@apostrophecms/page
settings with any language you'd like) to existing locale. The prototype doesn't include any UI configuration ("Translate with ...), it translates by default and if enabled.beforeLocalized
event, finds the (only) provider, extracts the translation meta data, sets the meta state topending
and executes the provider's translation handler.translated
and returns the translated data to the core.finalized
(once) and prevents the meta to be copied to the published doc. Edit and verify in the debug tab the new and final state. Inspect the published document directly in the mongo database -aposTranslationMeta
property shouldn't be found.