Jump to content

Translate diffForHumans strings


dandju

Recommended Posts

Hi,

Is it possible to translate the "diffForHumans" date strings within the client area? (using WHMCS 8.1)

Eg. in the right-side Ticket Information box on a ticket, it says "Last change: 5 months ago" - I would need to change the "5 months ago" to another language (preferable to that used by the logged in customer).

As I assume the Carbon's diffForHumans function is used here, I have tried to set it in the configuration.php file to "Carbon\Carbon::setLocale('de');" ... but did not work - I assume it gets overwritten somewhere in the WHMCS core.

Any ideas?

Thank you!

Link to comment
Share on other sites

Same for the /cart/domain/renew page

Expire date: 15 Jan 2021 (2 weeks from now)

Don't know if this is also Carbon, but couldn't find any translation string in the English.php lang file.
And "15 Jan 2021" does also not match the chosen date format in the WHMCS settings ...

Link to comment
Share on other sites

15 hours ago, dandju said:

Eg. in the right-side Ticket Information box on a ticket, it says "Last change: 5 months ago" - I would need to change the "5 months ago" to another language (preferable to that used by the logged in customer).

are you using a custom theme? sidebars would be on the left by default..it should already translate...

fHgAfSg.pngSAf8t4G.png0b0Uvkx.png

what are you seeing ?

15 hours ago, dandju said:

Same for the /cart/domain/renew page

Expire date: 15 Jan 2021 (2 weeks from now)

if I look at the domain renewals page in 21 or Six, then I see....

DARUGK0.png

6Q895aQ.png

i'm only checking in v8.1b1 (as I haven't updated yet), but I assume the GA release hasn't broken this.

Link to comment
Share on other sites

Thanks Brian for the update.

Sorry, yes on the left side; using the default "twenty-one" theme.

BUT I have just noticed that this only applies to some languages - I guess to those that are not by default shipped with WHMCS.

German is indeed working fine; the language in my case that does show english diffforhumans is "Bosnian" (which is similar to Croatian, which is working fine).

Do you by chance now how I can set the ISO code that will be passed to Carbon? Or how the language is passed to Carbon?

Tried to set $_LANG['locale'] = "hr_HR";  in the translation file, but this did not work.

Thanks! And happy new year!

Edited by dandju
Link to comment
Share on other sites

the Carbon translations are available in /vendor/nesbot/carbon/src/Carbon/Lang and I can see three files in there...

  • hr.php
  • hr_BA.php
  • hr_HR.php

i'm assuming the hr_BA.php contains Bosnian strings, but you'd be able to confirm that better than me... they look to be modified versions of the files available at the Carbon GitHub site.

however, I don't know whether WHMCS owns these files in the sense that if you were to modify them, they will just get overwritten during an update - my suspicion is that they would.

you could try defining hr_BA in the locale field, but i'm not sure it would work (even if you reset the value with a hook).

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