Skip to content

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.

@sargreal
Copy link
Member

sargreal commented Feb 3, 2025

@Henrixounez thank you for this implementation of #484

However as I mentioned there, I think this implementation is too user specific (different placeholder syntaxes may exist).

Therefore I would like to include this in an implementation of #467. This would allow anyone to use this placeholder syntax, and give them enough customization options.

@Henrixounez
Copy link
Author

@sargreal Yes, sure ! Created this implementation as I needed this on my project and saw other people needed it as well so I shared it here but if the same result can be made in a more generic way feel free to include it somewhere else :)

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.

3 participants