dOctype Posted March 2, 2015 Share Posted March 2, 2015 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: 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"} 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted March 2, 2015 Share Posted March 2, 2015 (edited) 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 March 2, 2015 by Kian 0 Quote Link to comment Share on other sites More sharing options...
dOctype Posted March 2, 2015 Author Share Posted March 2, 2015 Hi Kian! thanks for your reply, i made exactly what you told me, but I still continue viewing the timestamp in English I'm using "Flat" WHMCS theme.. maybe they made something to force English, I don't know.. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted March 2, 2015 Share Posted March 2, 2015 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" 0 Quote Link to comment Share on other sites More sharing options...
dOctype Posted March 2, 2015 Author Share Posted March 2, 2015 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 2, 2015 Share Posted March 2, 2015 (edited) 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 March 2, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
dOctype Posted March 2, 2015 Author Share Posted March 2, 2015 Ok, I will get that on mind. Thanks a lot. 0 Quote Link to comment Share on other sites More sharing options...
esat Posted March 20, 2016 Share Posted March 20, 2016 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 20, 2016 Share Posted March 20, 2016 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.