WhyEs Posted May 1, 2014 Share Posted May 1, 2014 Hi all, I noticed the formatted date in the mail templates (e.g. order_conf.html) is not translated. If i change the date format in BO to 'd F Y / H:i:s', the month is not translated. Is this a bug or is it supposed to work like this? Thanks! Link to comment Share on other sites More sharing options...
WhyEs Posted May 30, 2014 Author Share Posted May 30, 2014 Anybody? Link to comment Share on other sites More sharing options...
CartExpert.net Posted May 30, 2014 Share Posted May 30, 2014 Hi. You mean you want to display the actual name of the month? Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
WhyEs Posted May 30, 2014 Author Share Posted May 30, 2014 (edited) Thanks for your reply. We want to use a long date format in our mailtemplates, translated in Dutch (e.g. '30 mei 2014'). PaymentModule.php uses the following code to format a long date: Tools::displayDate(date('Y-m-d H:i:s'),null , 1), This however results in an English long date, which is not what we want. I tried hacking translating the resulting English date: $date_array = explode(' ', Tools::displayDate(date('Y-m-d H:i:s'), null , 1)); $custom_date = $date_array[0] . ' ' . strtolower($this->l($date_array[1], $order->id_lang)) . ' ' . $date_array[2]; This returns '30 May 2014', so it seems there's another problem, as for some reason it won't translate. I tried a simple 'echo $this->l('Yes', $order->id_lang)' for the sake of testing, which returns 'Yes' instead of 'Ja'. So, q1: is there an easy way or nice implementation to get a fully translated long date into a controller (or template!)? q2: is the translation functionality unavailable in a controller, or am I doing something wrong? Thanks in advance! Edited May 30, 2014 by WhyEs (see edit history) Link to comment Share on other sites More sharing options...
WhyEs Posted June 2, 2014 Author Share Posted June 2, 2014 Bump. Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 2, 2014 Share Posted June 2, 2014 Hi. You can define an array, with the names of the months, the index being the numeric representation of the month (1 to 12). The values in the array would be translatable, so defined by HTMLTemplateInvoice::l('[MONTH_NAME_HERE]'); Regards. Robin. The CartExpert Team Link to comment Share on other sites More sharing options...
WhyEs Posted June 2, 2014 Author Share Posted June 2, 2014 (edited) Hi Robin, Thank you for your reply. So what you're suggesting is: 1) create an array with the month names using the numeric representations as index ('1' => 'january', '2' => 'february') 2) match month and translate using HTMLTemplateInvoice::l('[month]'); I'm not really sure what you mean by #1. Using 'Tools::displayDate(date('Y-m-d H:i:s'),null , 1)' I already have the month name, so there's no need to use an array for that. Are you sure it's 'HTMLTemplateInvoice'? I did a projectwide search on 'HTMLTemplateInvoice' and I noticed it's used in the PDF class. The problem I described exists in the mailtemplates (e.g. order_conf.html) so I'm not really sure if I should be using 'HTMLTemplateInvoice' in PaymentModule.php. - edit - Using 'HTMLTemplateInvoice' in PaymentModule.php also raises an error: PHP Fatal error: Call to protected method HTMLTemplateCore::l() from context 'PaymentModule' in /[...]/htdocs/override/classes/PaymentModule.php on line 639 Edited June 2, 2014 by WhyEs (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 Hi. Sorry, for some reason I had the invoice in my mind. ))) The changes need to be made in PaymentModule.php Probably the easiest way to do this, is to rather have the English name of the months as indexes. $months['January'] = Mail::l('January', (int)$order->id_lang) etc. You then retrieve only the month name: $current_month = date('F'); $custom_date = str_replace($current_month, $months[$current_month], Tools::displayDate(date('Y-F-d')); This should work. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
WhyEs Posted June 3, 2014 Author Share Posted June 3, 2014 (edited) Hi Robin, Thank you for your reply. I did a quick test using '$custom_date = Mail::l('January', (int)$order->id_lang);' but this returns 'January' instead of 'januari'. The month-translations are in the front-end dictionary, should I be using another class/method to access it? Edited June 3, 2014 by WhyEs (see edit history) Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 Hi. Check if this file exists: mails/[LANGUAGE_ISO_CODE]/lang.php You need to add the translations there. Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
WhyEs Posted June 5, 2014 Author Share Posted June 5, 2014 Hi Robin, I added the translations to mails/nl/lang.php and it's working fine, thanks! We still have another issue which unfortunately hasn't been noticed by the moderators. Is there any chance somebody could look into it? We'd really appreciate it! Link to comment Share on other sites More sharing options...
vekia Posted June 5, 2014 Share Posted June 5, 2014 similar thread but in polish: http://www.prestashop.com/forums/topic/325207-data-godzina-zam%C3%B3wienia-w-email/ you can change date in that way: change this line: '{date}' => Tools::displayDate(date('Y-m-d'),null , 1), into this: '{date}' => date('Y-m-d'), you can use any date format there you want, the main problem is with Tools::displaydate - but this function isn't necessary! Link to comment Share on other sites More sharing options...
WhyEs Posted June 6, 2014 Author Share Posted June 6, 2014 Thanks Vekia, I think the problem's solved. This topic really needs attention though, as we're desperate to get it fixed. I'd really appreciate it if you could look into it! Also, if it's posted in the wrong forum or it should be a bugreport, please do tell se we can take action. Link to comment Share on other sites More sharing options...
WhyEs Posted June 10, 2014 Author Share Posted June 10, 2014 (edited) . Edited June 10, 2014 by WhyEs (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted June 10, 2014 Share Posted June 10, 2014 thank you for informations, i marked topic title as solved. and of course, im going to check thread you linked with regards, Milos Link to comment Share on other sites More sharing options...
WhyEs Posted June 10, 2014 Author Share Posted June 10, 2014 Thanks Vekia! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now