Jump to content

[resolved][bug] Long date is not translated in English with Smarty/PS 1.6.0.11


Recommended Posts

Hi Guys,

 

I am developing a module and I have the texts of my template translated, excluding the long date (eg. lundi 02 mars) !

I have discover that my date variable is translated in French and in Spanish, but not in English.

Try to add this to a template:

{$smarty.now|date_format:'%A %d %B'}

When you switch From French to English, the French long date is appearing ! And when you switch to Spanish, the long date is corrected translated in Spanish !

I have tried to add the "setlocale" in my module, but nothing happen, except that "en_US" is doing a 500 error....

Here is how I have forced the setlocale in my module:

$lang = $this->context->cookie->id_lang;
if($lang == 1)
   setlocale(LC_TIME, 'fr_FR.UTF-8', 'fr_FR.utf8');
elseif($lang == 2)
   setlocale(LC_TIME, 'en_EN.UTF-8', 'en_EN.utf8');
elseif($lang == 3)
   setlocale(LC_TIME, 'es_ES.UTF-8', 'es_ES.utf8');

The cookie value is ok, I checked. Any idea to correct this ?

 

 

PS 1.6.0.1 with the French, English and Spanish installed.

Edited by monpoulet (see edit history)
Link to comment
Share on other sites

Hi M4,
 
Thank you for replying, but I have also a 500 error.
Here are the lines:

Invalid date
at line 689 in file classes/Tools.php

and here is the code:

688. 		if (!Validate::isDate($date) || !Validate::isBool($full))
689. 			throw new PrestaShopException('Invalid date');

I think it's a bug in the core of Prestashop as it's working in Spain and in French. Or should the date espacially formatted from a time stamp for US ?
 
Best regards,
 
Marc

post-401889-0-21161400-1425147467_thumb.jpeg

post-401889-0-40358200-1425147468_thumb.jpeg

post-401889-0-09744300-1425147469_thumb.jpeg

Link to comment
Share on other sites

Just a precision:

I have tested on the server, but "outside" Prestashop, it's working.

Have a try:

call this: strftime("%A %d %B", '1425147349') in php

It should show:

  • in french: Samedi 28 février
  • in spanish: Sábado 28 febrero
  • in english: Saturday 28 February

 

In english it gives me a 500 error ? A new bug of PS 1.0.6.11 ? May a Super-Extra-Admin have a look ?

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

Well sorry I read your point, but I do not understand it.

 

again it is a smarty function, I can not see why you link it to the Tools class. We do setlocale so maybe this is in cause. You need to overwrite it probably in a smarty modifier.

 

https://github.com/PrestaShop/PrestaShop/blob/1.6/config/config.inc.php#L140-L143

 

http://www.smarty.net/forums/viewtopic.php?p=68792&sid=d2df0dbaad616aedc03e28f9f55ef1c8

 

Regards

  • Like 1
Link to comment
Share on other sites

  • 6 years later...

Hello @monpouletHow are you doing?
I know this is a super old topic, but I am having exactly the same problem as you are currently having with date translations and maybe by some miracle you will see this message in time.
Apparently smarty is not able to translate the month of December for me and therefore does not show the date. This is the format I am using "%e %b %Y" when it is in French it does not show, but in English it shows the date correctly. I tried changing the format to %e %Y and in both languages it shows the date correctly, so the problem comes with the translation of December to French.
He also has problems with these months Février and Août, they all have an accent including Décembre

image.thumb.png.99fce1012c21c99a3350d5758a76906f.png

In English
image.png.4d10c458d7532fcb7eab55f59eca3ae7.png

But in French
image.png.45fab988ea222dbf48feeb42d105dc32.png

Edited by MrEduar (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...