I have a multilingual site and use Babel with BabelTranslate to copy a page. In the German version, I have a link [[~2]] that I want to be translated into the corresponding English version. Simply replacing it with a ereplace in Fenom does not work, possibly because the placeholder is rendered before. How do you handle things like this on your sites anyway?
You can create a plugin in OnDocFormSave that transforms the normal link tag to a corresponding one using BabelTranslation. This tag should work in every context and does not have to be transformed later by BabelTranslate.
thanks for the idea! The plugin uses $modx->_output to replace all occurrences of [[~12345]] with [[~[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`12345`]]]].
When you edit the page again with a Rich Text Editor, the value [[~[[BabelTranslation? &contextKey=`[[*context_key]]` &resourceId=`12345`]]]] may confuse users?
Another idea is to use the OnBabelDuplicate plugin event to replace the correct ID from the context. However, this may break when changes are made later
But if you reset the link back, you have to regard the context in different contexts then the Babel default context. I can add that plugin into Babel, when you create a PR.