Jump to content

Language Translation


Ugyen

Recommended Posts

Hi WHMCS Community,

 

I have applied your template 6 customization logic from http://docs.whmcs.com/Editing_Client_Area_Menus for Add a social media panel to the end of the sidebar includes/hooks/socialMediaPanel.php and Add support hours and a custom message to the sidebar on the submit ticket page in my WHMCS installation. Problem here is I can't translate to other language I have used both ways.

'label' => Lang::trans('yourstringhere'), under arrary for includes/hooks/addSupportHours.php. Can't able to translate the last line 51 and 52 . I have applied as you mentioned using array but not. I have shared screenshot for which It need to be translated. Looking forward hearing from you.

 

With Best Regards,

 

Ugyen

translate.png

Link to comment
Share on other sites

Hi Ugyen,

 

there would be a few ways to do this, depending on the complexity of your output message... for this, you can use sprintf and Language Overrides...

 

in the hook...

        $supportHours->setBodyHtml(
           $supportIsOpen
               ? sprintf(Lang::trans('supportdeptopen'),$greeting)
               : sprintf(Lang::trans('supportdeptclosed'),$greeting)
       );
   });
}

and then for the Language Overrides, just add entries to your language override file(s)...

 

$_LANG['supportdeptopen'] = "Hi%s! We're open and will respond to your ticket soon!";  
$_LANG['supportdeptclosed'] = "Don't worry%s! We will respond on the next business day. Sit tight!";

if you don't need to pass any variables in your translated message, then it's simpler and you won't need to use sprintf.

 

        $supportHours->setBodyHtml(
           $supportIsOpen
               ? Lang::trans('supportdeptopen')
               : Lang::trans('supportdeptclosed')
       );
   });
}

and...

 

$_LANG['supportdeptopen'] = "We're open and will respond to your ticket soon!";  
$_LANG['supportdeptclosed'] = "We will respond on the next business day. Sit tight!";

Link to comment
Share on other sites

  • 3 years later...

I tried but not success.

Can you add how need look that code?  

This is from tutorial

$supportHours = $primarySidebar->addChild('Support Time');

I try include this

Lang::trans('titlenamesupporttime')

but without results.  

How we can properly implement lang trans?

If use lang trans like for child or  body, not work.

I think i need diferent use lang trans code for title?

Can you show me how?  Thank you!

Link to comment
Share on other sites

15 hours ago, nedel said:

How we can properly implement lang trans?

the support hours lie changes to....

$supportHours = $primarySidebar->addChild('Support Hours')->setLabel(Lang::trans('supporthours'));

and then define your support hours heading language string in every language that your site uses (using Language Overrides)....

$_LANG['supporthours'] = "Brian's Support Hours";

CMg4V4U.png

Link to comment
Share on other sites

HI Brian!

Happy new year, i wish all best for you!

And thank you very much for code.  That  i need,  now  title translated.   

->setLabel(Lang::trans('supporthours'))

 

Now  all words translated from that hook.   

 Thank you!!

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