Ciaran Baker
Member
Hello all,
I'm working on a simple add-on that intercepts phrases before they are rendered, performs some logic, and then returns the phrase. I've currently got the following code which works:
I can see this being applied to certain phrases on my forum. However, it seems that any phrases that are referenced in templates using
Is there a different method that is used in XenForo for rendering these sorts of phrases?
I'm working on a simple add-on that intercepts phrases before they are rendered, performs some logic, and then returns the phrase. I've currently got the following code which works:
Code:
<?php
namespace AddonName\XF;
class Language extends XFCP_Language
{
public function renderPhrase($name, array $params = [], $context = 'html', array $options = [])
{
// Call the parent method to get the original phrase
$phrase = parent::renderPhrase($name, $params, $context, $options);
// Apply custom logic to phrase
$phrase = $this->doMyCustomLogic($phrase);
// Return updated phrase
return $phrase;
}
I can see this being applied to certain phrases on my forum. However, it seems that any phrases that are referenced in templates using
{{ phrase('phrase_name') }}
don't get updated. For example, all phrases in the Admin Panel get updated. Phrases used in widgets seem to be updated, as well as my navigation bar entries.Is there a different method that is used in XenForo for rendering these sorts of phrases?
Last edited: