Jump to content

Hook with variable from language file


Lek

Recommended Posts

Good morning,

I add a link via hook in the main navigation bar (client area) in the "support" drop down menu. It works perfectly:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Support'))) {
       $primaryNavbar->getChild('Support')
           ->addChild('Emergency Contacts', array(
               'label' => 'Contacts',
               'uri' => '../contacts.html',
               'order' => '100',
           ));
   }
});

 

Now the name of the new link is ... ('Support') ...

I would like this word (Support) to change depending on language.

So I think I have to first add the string in any language file I want to use, for example, for English

$_LANG['extralinkSupport'] = "Contacts";

for Italian:

$_LANG['extralinkSupport'] = "Contatti";

And how to I implement the above php code of the hook so I will have a different word depending on the language?

Thank you.

Link to comment
Share on other sites

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
if (!is_null($primaryNavbar->getChild('Support'))) {
	$primaryNavbar->getChild('Support')
	->addChild('Emergency Contacts', array(
			'label' => Lang::trans('extralinkSupport'),
			'uri' => '../contacts.html',
			'order' => '100',
	));
}
});

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated