Skip to content
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

feat(provider-deepl): omit placeholders plugin option #487

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Henrixounez
Copy link

Changes

Adds an optional boolean omitPlaceholders provider option for the DeepL Provider that handles text inside double curly brackets, that can be used as placeholders or variable text.

Asked by #484 , but I also had the same need with collaborators on Strapi that want to mass translate text with those {{text}} inside.

Explanation

Replicated the process explained in the example provider by Deepl:
https://developers.deepl.com/docs/resources/examples-and-guides/placeholder-tags
https://github.com/DeepLcom/deepl-python/blob/main/examples/mustache/README.md

Steps:

When omitPlaceholders is true

  • ⬅️ Before the translation: it creates and fills a temporary placeholderTexts array that contains the text that should be kept, while replacing the text with a simple <m id=xx /> tag to keep the position of the placeholder in the text.

  • ➡️ After the translation: it replaces back the tags with the original text thanks to the index saved inside the tag id.

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.

1 participant