WebsiteBaker Support (2.12.x) > General Help & Support

Translation of dates

<< < (2/2)

rumen:
I put the code there but there are no changes still the same settings.  Cleared the cache but no any effect. 

Gast:
i'm thinking about this and play a little bit...
from my eyes (at the moment)...
-
- if you use setlocale as global definition (like my words in the top) in framework/initialize.php or index.php from the template, you get a problem on multi-lingual pages, because, then, i get also my localistation on pages with other languages, that means, a bulgarian date like 20 февруари 2019, 17:11 is also visible, if you visit the english news

so i build this code for the view.php from the news module - dont forget, it is lost in the next upgrade  :-(

in my example project, i use german, italien and bulgarian as languages

go into modules/news/view.php and search for this line  (~ 327)


--- Code: ---$publ_date      = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
--- End code ---

add this code in the next line(s)


--- Code: ---if(LANGUAGE == 'DE'){
                    $locale = 'de_DE.UTF-8';
                    setlocale(LC_ALL, $locale);
                    $publ_date      = strftime('%d %B %Y', strtotime($publ_date));
                }
                elseif(LANGUAGE == 'IT'){
                    $locale = 'it_IT.UTF-8';
                    setlocale(LC_ALL, $locale);
                    $publ_date      = strftime('%d %B %Y', strtotime($publ_date));
                }else{
                    $locale = 'bg_BG.UTF-8';
                    setlocale(LC_ALL, $locale);
                    $publ_date      = strftime('%d %B %Y', strtotime($publ_date));
                }
--- End code ---
Dont forget to change the setlocale-Definition. see here the language code -> https://www.w3.org/WAI/ER/IG/ert/iso639.htm and use lower and Upper Letters like the example

if you need only two languages, remove the elseif-part in the middle. if you need more languages, copy the elseif-Part in the middle
Important!!:  Use your default-Language (see WB-settings) in the else-Part as last option

Results:

Bulgarian


Italian

rumen:
WORKS PERFECT!

Thanks a lot mate!

Navigation

[0] Message Index

[*] Previous page

Go to full version