Translation of dates

rumen

WORKS PERFECT!

Thanks a lot mate!

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)

$publ_date      = date(DATE_FORMAT,$post['published_when']+TIMEZONE);

add this code in the next line(s)

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));
                }

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

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

zirzy


Gast

ah... sorry, it was a older initialize.php with this comment

actual version WB 2.12.1 - /framework/ initialize.php  behind this ~Ln 319

    \date_default_timezone_set('UTC');

that's a good place, but you lost it in the next upgrade. normalize, it doesn't matter, where you are in the initialize. important is, that you're not inside of a function there

in my test's, it works also, if i add this line in the top of my template-index.php, maybe, somebody can confirm this - looks for me as the best solution

zirzy

Hi,

Yes, I got the same problem with news..

Is this initialize.php in framework folder? If yes, there was no deactivated lines on line ~ 290 what was telling something about time and date format.. On line ~ 500 is time and date but no deactivated lines.. I don't know if this is correct but I inserted code to line 504 and now it's working  (Y)

Gast

normalize, the date-part like day or month come's from the PHP-date-function and you need a setlocale-definition in your initialize.php  ~ Ln 290 (see the deactivated lines there) or try to add there this line

setlocale (LC_ALL, 'bg_BG');


but the jquery and the js-calendar has language files and maybe, the problem is solved, if you add there a translation

for jquery in include/jquery/i18n

for js-calendar ininclude/jscalendar/lang

both addons has a bulgarian translation

rumen

I noticed that months are not translated in some modules like News module for example, but they does not exist in the language file as they are in the My Calendar for example. Where that months are located to translate them in the multi language sites? I could not find them anywhere and also here in the forum did not find any info about that. Maybe I didn't search as needed but ...

Regards,