I need to surround Wordpress Shortcodes for translating the content. These are the pre-requisites of the issue:
- I've to surrounding "the" shortcode, not the shortcode's content. For example
<div class="notranslate">[shortcodename parameter="1"]</div>Shortcode content in italian<div class="notranslate">[/shortcodename]</div> - After that, I need to remove the .notranslate tag from the API response
[shortcodename parameter="1"]Shortcode content in english[/shortcodename]
Can anyone help me? I'm not expert in RegEx. The plugin is writed in PHP and I'm trying to use Wordpress API for better integration (for example It should be better if the tool matches only the registered shortcodes and escaping the default shortcode's escaping syntax). But the core of the request is find the right regexes for find and replace.
References
- Microsoft Translator Text API: https://docs.microsofttranslator.com/text-translate.html
- The Shortcode API: https://codex.wordpress.org/Shortcode_API
Regards Mattia