The previous solution doesn't work on 2.0.18.1. return strftime($Format, $Timestamp); is changed to $Result = strftime($Format, $Timestamp); or it doesn't exist? Is it possible to have the month names translated somehow?
changing setlocale variables in bootsstrap.php doesn't take effect.
where do i need to make these changes to change month names?
anyone has some help for me?
VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
speaking of dates, anyone know how i can change like 9:04 to Today 9:04 if it shows up todays time instead of a full date? (wich is given out by Gdn_Format::Date($this->User->DateFirstVisit) in the user profile at example)
Using setlocale() does not appear a good solution to me. As explained in the documentaiton, this function is process-wide, which means that on multithreaded Apache implementations, calling it may change the locale in other active threads. This can be a problem if your Apache server runs other services than Garden/Vanilla.
I did the following to solve this problem using Vanilla 2.0.18.1. It works by processing in PHP some of the date format placeholders (%a %A %b and %B)
Some of you may find it a bit complex or overkilll, but it works properly in any environment. I am not a Vanilla developer, but of course the following code may be modified and included wherever anyone may need it.
Step 1 : create arrays for month and day names in the standard locale
In Garden/applications/dashboard/locale/en-CA/definitions.php look for :
@MacWebsk in which language are you experiencing your problem ? Does it occur both for long and short month names ? I checked again and it works on my dev and production sites.
// If the timestamp is the same year, show the month and date
$Format = T('Date.DefaultDayFormat', '%B %e');
} else if (date('Y', $Timestamp) != date('Y', $Now)) {
// If the timestamp is not the same year, just show the year
$Format = T('Date.DefaultYearFormat', '%B %Y');
} else {
// Otherwise, use the date format
$Format = T('Date.DefaultFormat', '%B %e, %Y');
}
Comments
In bootstrap.php, look for:
$SetLocale = str_replace('-', '_', CurrentLocale).'.'.$Codeset; setlocale(LC_ALL, $SetLocale);
Change to:
$SetLocale = str_replace('-', '_', CurrentLocale).'.'.$Codeset; if ($CurrentLocale == 'hu') setlocale(LC_ALL, $SetLocale, 'hungarian'); else setlocale(LC_ALL, $SetLocale); //setlocale(LC_ALL, $SetLocale);
In library/core/class.format.php, look for:
return strftime($Format, $Timestamp);
Change to:
return iconv('ISO-8859-2', 'UTF-8', strftime($Format, $Timestamp)); //return strftime($Format, $Timestamp);
Don't forget to change language code, name and code page to your language!
return strftime($Format, $Timestamp);
is changed to
$Result = strftime($Format, $Timestamp);
or it doesn't exist?
Is it possible to have the month names translated somehow?
How can i change "desember 22" to: "22 desember" ?
All i want is to swap the order of month and day in LastCommentDate.
Thanks in advance.
changing setlocale variables in bootsstrap.php doesn't take effect.
where do i need to make these changes to change month names?
anyone has some help for me?
speaking of dates, anyone know how i can change like 9:04 to Today 9:04 if it shows up todays time instead of a full date? (wich is given out by Gdn_Format::Date($this->User->DateFirstVisit) in the user profile at example)
Using setlocale() does not appear a good solution to me. As explained in the documentaiton, this function is process-wide, which means that on multithreaded Apache implementations, calling it may change the locale in other active threads. This can be a problem if your Apache server runs other services than Garden/Vanilla.
I did the following to solve this problem using Vanilla 2.0.18.1. It works by processing in PHP some of the date format placeholders (%a %A %b and %B)
Some of you may find it a bit complex or overkilll, but it works properly in any environment. I am not a Vanilla developer, but of course the following code may be modified and included wherever anyone may need it.
Step 1 : create arrays for month and day names in the standard locale
In Garden/applications/dashboard/locale/en-CA/definitions.php look for :
$Definition['Date.DefaultDateTimeFormat'] = '%B %e, %Y %l:%M%p';
Insert after it
Step 2 : Modify Date_format to use those arrays
Modify library/core/class.format.php to use those arrays
Look for
After those lines, insert :
Step 3 : translate the month names
In your locale, translate the arrays
For example in french :
Brilliant reply
There was an error rendering this rich post.
It doesn't work for me. Instead month names, show only one letter.
Anyone else tried Olivier_Chevet's instructions?
I realized I forgot a step 4 in my instructions.
Step 4 : add english translations for months
you need to add the month names in English. Several location are possible. I came up with the following.
in the file application/dashboad/locale/en-CA/definitions.php look for
$Definition['Date.DefaultDateTimeFormat'] = '%B %e, %Y %l:%M%p';
After this line, add :
@MacWebsk in which language are you experiencing your problem ? Does it occur both for long and short month names ? I checked again and it works on my dev and production sites.
you don't have to use arrays, just set your config file (conf/config.php)
insert new line anywhere like this:
(this means all names will be hungarian)
@Olivier_Chevet hi, step 4 of your instructions is the same with step 1?
My long month names (Slovak) are visible just as one letter. I follow your 3 steps instructions carefuly.
check my forum site pls: macweb.sk/forum/
thanks
@jungica: ok, solved, thank you very much mate. koszonom
@jungica: nice fix, but the order is still backwards...
Right now, it says "februar 13" when i need "13 februar".
Any way to change the order?
Thanks in advance.
which language do you want to use?
Norwegian (nb_NO)
put into config: $Configuration['Garden']['Locale'] = 'nb_NO'; and search for the time display and change
(februar 13)
to
(13 februar)
I added "$Configuration['Garden']['Locale'] = 'nb_NO';" to /conf/config.php, and it shows norwegian month names perfectly.
But there are no "%B" or "%d" in the entire /conf/config.php document.
Could you post your time display code?
try library\core\class.format.php line 468?
or library\core\functions.general.php line 927?
Found this when i searched for %B:
Found this when i searched for %d:
Found this when i searched for %B:
Found this when i searched for %d:
Did not find anything in either documents when i searched for %B %d.
Please advice.