Would anyone be able to tell me how/if I can use global translations in the panel? In the code, you can use t(‘translation-key’). Would it be possible to use this function or another method to get the global translation in the panel?
In textareas, you could use placeholders like `{{ my.super.key }} which you could then replace in kirbytext hooks. In blocks or other fields, you could also work with a preg_replace callback.
Yes, I think so, because different methods for different use cases don’t really make that much sense. Basically, you would search for strings within given delimiters (it’s up to you, whether you use double curly braces or something else that is not otherwise used), and then call the t() method on those matches.
echo preg_replace($page->content()->value(), 'translation key in text', t('translation key in code');
Would this be the correct syntax?
Also, is there a way to do this globally across the whole project so I wouldn’t have to wrap every content field with preg_replace?