This should do the trick:
Replace\{\{(?:\s|\n)*(?!(?:'|\s|\n))(.*')(?:\s|\n)*(\|(?:\s|\n)+translate)\b
with{{ '$1 $2
Explanation:
\{\{
- match two open braces(?:\s|\n)*
- match any number of whitespace characters(?!(?:'|\s|\n))(.*')
- capture group 1; match any continuous string of not'
characters followed by a single'
(?:\s|\n)*
- match any number of whitespace characters(\|(?:\s|\n)+translate)
- capture group 2; match|
followed by at least one, or more, whitespace character and then the wordtranslate
.\b
- match a word boundary