Jump to content

Announcements timestamp in other language


dOctype

Recommended Posts

Hello, I'm trying to change the timestamp's language in announcements section. My WHMCS is using Spanish as default language, but, I see the timestamp in English:

 

whmcs.gif

 

How can I change it? I can't see any reference in JSs or language files.. HELPPP! :)

 

Regards,

Ignacio.

 

- - - Updated - - -

 

The call to the timestamp is:

{$announcement.timestamp|date_format:"%A, %B %e, %Y"}

Link to comment
Share on other sites

You have to setlocale() with LC_TIME. Put this on top of your announcements.tpl.

 

{php}
setlocale(LC_TIME, "es_ES"); # where es_ES should be changed accordingly to it_IT, us_US etc. when user switch language
{/php}

 

But it's not enough since some languages use accented letters. For example in Italian days are lunedì, martedì, mercoledì etc. and they will cause a char code error so you have to add this utf8_encode to $announcement.timestamp:

 

{$announcement.timestamp|date_format:"%A, %B %e, %Y"|utf8_encode}

 

Anyway probably the best approach is to define the setlocale() inside AdminAreaPage hook point so that you don't need to add this code on top of your all your tpl files where there's a date.

Edited by Kian
Link to comment
Share on other sites

in configuration.php use add this function at the end of file

setlocale(LC_TIME, 'sp_spain');

change "sp_spain" with the correct locale name installed in your server, more info

 

i tried it with "nld_nld" (Dutch) and it changes "Monday, March 2, 2015" to "maandag, maart 2, 2015"

Link to comment
Share on other sites

YEsss!!! Thanks Kian and sentq, the problem was I was changing announcements.tpl and I had to change viewannouncements.tpl that was the file with language problem.

 

It worked like this:

 

{php}

setlocale(LC_TIME, "es_ES");

{/php}

 

and:

 

{$announcement.timestamp|date_format:"%A, %e de %B - %Y"|utf8_encode}

 

Thanks again,

Regards.

Link to comment
Share on other sites

Ignacio,

 

it's worth remembering that your solution won't work when WHMCS v6 is released later this year - as I believe it will start using Smarty v3, you will no longer be able to use {php} in the templates.

 

therefore, it might be easier to use sentq's configuration.php suggestion or Kian's hook idea...

 

setlocale(LC_TIME, 'es_ES.UTF-8');

Edited by brian!
Link to comment
Share on other sites

  • 1 year later...

Hello,

I have same issue $announcement.timestamp, language problem for Turkish.

That setlocale(LC_TIME, 'tr_TR.UTF-8'); solution in the configuration.php doesn't work.

 

Also belowed solution doesn't work anymore in 6.2.2.

{php}

setlocale(LC_TIME, "TR_TR");

{/php}

 

Anybody can help me about that?

Link to comment
Share on other sites

it might be worth opening a ticket with support to see if this is a bug or intentional.

 

you could certainly use a Smarty replace (multiple) to change the English month names to Turkish - that could be a last resort solution if setlocale continues to fail.

 

http://forum.whmcs.com/showthread.php?98194-Date-in-another-language&p=449670#post449670

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