Jump to content

Translate Time Sidebar Recent Tickets and Ticket Information


Drweb

Recommended Posts

Would anyone know how to translate the sidebar Recent Tickets and Ticket Information?

 

Currently he is showing in English and would need to translate to Portuguese of Brazil!

 

It is showing for example "23 hours ago" but I need it to be displayed "23 horas atras".

 

Prints:

 

22.png.994405ff5b232888805d594417f0bb52.png

 

whmcstranslate.png.c7d9ac639018d07f5c250d3427661805.png

Link to comment
Share on other sites

there are about five ways to fix this, but the most important one is to report it as a bug to WHMCS - the code needed to fix this is already available to the WHMCS files, but it's not being used by the developers... technically, it's known as "Carbon Localisation" and it's very simple to do when you have access to the source code, so why WHMCS didn't think to add it themselves, i've no idea.... laziness or perhaps another failure of the extensive testing they supposedly do before each release. :roll:

 

anyway, if you can get them to make the change to their code, then that's the best solution - the downside is that it will likely take them weeks/months/years(?) to do this, so it's no help to you in the short-term.

 

the other ways would effectively require you to use Action hooks to either modify or recreate the existing sidebars... either via a Carbon localisation method, a string replace method (potentially using language strings), or by modifying the sidebar template.

Link to comment
Share on other sites

there are about five ways to fix this, but the most important one is to report it as a bug to WHMCS - the code needed to fix this is already available to the WHMCS files, but it's not being used by the developers... technically, it's known as "Carbon Localisation" and it's very simple to do when you have access to the source code, so why WHMCS didn't think to add it themselves, i've no idea.... laziness or perhaps another failure of the extensive testing they supposedly do before each release. :roll:

 

anyway, if you can get them to make the change to their code, then that's the best solution - the downside is that it will likely take them weeks/months/years(?) to do this, so it's no help to you in the short-term.

 

the other ways would effectively require you to use Action hooks to either modify or recreate the existing sidebars... either via a Carbon localisation method, a string replace method (potentially using language strings), or by modifying the sidebar template.

 

I appreciate your message.

 

I have already reported this to Whmcs, but you know how it is, did not give me a solution.

 

Unfortunately, every update a new problem appears.

 

And I'm not aware enough to resolve this issue.

Link to comment
Share on other sites

I appreciate your message.

I have already reported this to Whmcs, but you know how it is, did not give me a solution.

did they confirm it as a bug?

 

Unfortunately, every update a new problem appears.

sadly how true.

 

And I'm not aware enough to resolve this issue.

below is a quick hook I wrote earlier for the first problem and will only work for pt_BR (other languages will continue to use English)... to use, create a new .php file in /includes/hooks and paste into it...

<?php    

//Support Ticket Localisation for pt-BR only.
//provided by brian!

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;
use Carbon\Carbon;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $vars)
{
   if(Lang::trans('locale') == 'pt_BR') {

       global $tid;
       $locale = Lang::trans('locale');

       $lastreply = Capsule::table('tbltickets')
                   ->where('tid',$tid)
                   ->value('lastreply');

       Carbon::setLocale($locale);
       $reply = new Carbon($lastreply); 

       if (!is_null($vars->getChild('Ticket Information'))) {
               $vars->getChild('Ticket Information')
                       ->getChild('Last Updated')
                       ->setLabel('<span class="title">'.Lang::trans('cPanel.usageLastUpdated').'</span><br />'.$reply->diffForHumans());
       }
   }
});

 

7yNtcc7.png

 

the other sidebar would be trickier to fix as we don't have access to the source code of the sidebar... without that, it would probably be quicker to recreate it from a new SQL query... or just remove the recent tickets sidebar!

Link to comment
Share on other sites

did they confirm it as a bug?

 

 

sadly how true.

 

 

below is a quick hook I wrote earlier for the first problem and will only work for pt_BR (other languages will continue to use English)... to use, create a new .php file in /includes/hooks and paste into it...

<?php    

//Support Ticket Localisation for pt-BR only.
//provided by brian!

use WHMCS\View\Menu\Item as MenuItem;
use Illuminate\Database\Capsule\Manager as Capsule;
use Carbon\Carbon;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $vars)
{
   if(Lang::trans('locale') == 'pt_BR') {

       global $tid;
       $locale = Lang::trans('locale');

       $lastreply = Capsule::table('tbltickets')
                   ->where('tid',$tid)
                   ->value('lastreply');

       Carbon::setLocale($locale);
       $reply = new Carbon($lastreply); 

       if (!is_null($vars->getChild('Ticket Information'))) {
               $vars->getChild('Ticket Information')
                       ->getChild('Last Updated')
                       ->setLabel('<span class="title">'.Lang::trans('cPanel.usageLastUpdated').'</span><br />'.$reply->diffForHumans());
       }
   }
});

 

7yNtcc7.png

 

the other sidebar would be trickier to fix as we don't have access to the source code of the sidebar... without that, it would probably be quicker to recreate it from a new SQL query... or just remove the recent tickets sidebar!

 

 

I have no words to thank you.

 

It worked perfectly!

 

Whmcs is taking care of this as a customization and not as a bug.

 

As such, I would courage you to please submit a request to our feature quests tracker where other users can contribute to and vote on your idea. Ideas with the most votes and activity from get reviewed by our team.

http://Http://requests.whmcs.com

 

 

In other words, they are not a little concerned about companies of other nationalities.

 

Another issue out of this topic is the translation of the sidebar of announcements, which is also in English and I need to get patching every month through a hook to fix this problem. And believe me, I have a ticket with them open from this August 23/2016 and so far nothing to resolve the problem, just inform them that they will resolve, but never resolve, as below:

 

CORE-10001 - Ensure when clicking on "Older Announcements" that older announcements are shown

CORE-8790 - Make Announcement 'By Month' Sidebar menu items translatable

 

whmcs2.png

 

And we have nothing to do, we just have to waste time fixing problems or at least trying problems that the developer should resolve.

 

Again, thank you very much for your help.

Link to comment
Share on other sites

Whmcs is taking care of this as a customization and not as a bug.

In other words, they are not a little concerned about companies of other nationalities.

that's a real shame if they think of it as a customization and not a bug... I suppose technically it isn't a bug (as they see it) because it's working as they intended... it's just that I think they should design for international clients whenever possible to do so... especially in the above example, when you need need to know the clients language and add one line of PHP code.

 

i've just rewritten the above hook to work for all languages...

 

qcCm2hM.pngpuZ4Ojy.png7tNeV9R.png

 

and if I can quickly do it as a hook on a Sunday afternoon, I can't see why it will take WHMCS years when they have access to the source code. :roll:

next step might be to try and translate the ticket creation date, but that requires another method and i'm not sure if WHMCS obeys the setLocale setting correctly - but that's for another time as i've had more than enough of WHMCS for today!

 

Another issue out of this topic is the translation of the sidebar of announcements, which is also in English and I need to get patching every month through a hook to fix this problem. And believe me, I have a ticket with them open from this August 23/2016 and so far nothing to resolve the problem, just inform them that they will resolve, but never resolve, as below:

as with the other problem, if WHMCS aren't going to resolve it, you're left with at least 4 options...

 

1. an action hook to recreate the SQL query and add the translations into the output.

2. an action hook to take the existing sidebar, loop through the array and translate the dates.

3. a template edit to translate the date using specific strings for one language.

4. a template edit to translate the dates using Language Overrides.

 

they could all be done, it's just a case of how much time/effort you want to put it... the simplest/quickest to do would be option 3 (e.g it's just one line of code) - you could edit /templates/six(or custom)/includes/sidebar.tpl and change...

 

{$childItem->getLabel()}

to...

{if  $language eq "portuguese-br" and $item->getName() eq "Announcements Months"}{$childItem->getLabel()|replace:'Jan ':'jan. '|replace:'Feb ':'fev. '|replace:'Mar ':'março '|replace:'Apr ':'abril '|replace:'May ':'maio '|replace:'Jun ':'junho '|replace:'Jul ':'julho '|replace:'Aug ':'agosto '|replace:'Sept ':'set. '|replace:'Oct ':'out. '|replace:'Nov ':'nov. '|replace:'Dec ':'dez.  '}{else}{$childItem->getLabel()}{/if}

 

BSe6UTn.png

 

xqznAgZ.png

 

the same principle should work for your recent tickets sidebar too - I don't seem to have that sidebar on my dev, but if you could find out the sidebar name, you could include it in the {If} statement and it would translate those strings... e.g you'd have to translate "hours ago", "weeks ago", "months ago" etc.

Link to comment
Share on other sites

that's a real shame if they think of it as a customization and not a bug... I suppose technically it isn't a bug (as they see it) because it's working as they intended... it's just that I think they should design for international clients whenever possible to do so... especially in the above example, when you need need to know the clients language and add one line of PHP code.

 

i've just rewritten the above hook to work for all languages...

 

qcCm2hM.pngpuZ4Ojy.png7tNeV9R.png

 

and if I can quickly do it as a hook on a Sunday afternoon, I can't see why it will take WHMCS years when they have access to the source code. :roll:

next step might be to try and translate the ticket creation date, but that requires another method and i'm not sure if WHMCS obeys the setLocale setting correctly - but that's for another time as i've had more than enough of WHMCS for today!

 

 

as with the other problem, if WHMCS aren't going to resolve it, you're left with at least 4 options...

 

1. an action hook to recreate the SQL query and add the translations into the output.

2. an action hook to take the existing sidebar, loop through the array and translate the dates.

3. a template edit to translate the date using specific strings for one language.

4. a template edit to translate the dates using Language Overrides.

 

they could all be done, it's just a case of how much time/effort you want to put it... the simplest/quickest to do would be option 3 (e.g it's just one line of code) - you could edit /templates/six(or custom)/includes/sidebar.tpl and change...

 

{$childItem->getLabel()}

to...

{if  $language eq "portuguese-br" and $item->getName() eq "Announcements Months"}{$childItem->getLabel()|replace:'Jan ':'jan. '|replace:'Feb ':'fev. '|replace:'Mar ':'março '|replace:'Apr ':'abril '|replace:'May ':'maio '|replace:'Jun ':'junho '|replace:'Jul ':'julho '|replace:'Aug ':'agosto '|replace:'Sept ':'set. '|replace:'Oct ':'out. '|replace:'Nov ':'nov. '|replace:'Dec ':'dez.  '}{else}{$childItem->getLabel()}{/if}

 

BSe6UTn.png

 

xqznAgZ.png

 

the same principle should work for your recent tickets sidebar too - I don't seem to have that sidebar on my dev, but if you could find out the sidebar name, you could include it in the {If} statement and it would translate those strings... e.g you'd have to translate "hours ago", "weeks ago", "months ago" etc.

 

 

Thank you! You did something that Whmcs never did.

 

I believe these codes and information will be very helpful to other people as well.

 

It's very nice to know there are still people like you.

 

Again, thank you.

Link to comment
Share on other sites

  • 1 month later...

Heya,

 

i was also looking for a solution but was able to fix it easily by changing just one string in:

 

../vendor/nesbot/carbon/src/Carbon/Carbon.php

Edit the file and look for this line (916)

 

static::setLocale('en');

 

Just change it to your desired language code..

i.e. for german change "en" with "de"

 

If you need to make custom translation go to:

 

../vendor/nesbot/carbon/src/Carbon/Lang/

 

you will find several language files here where you can modify your own.

 

Hope this helps

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