I think the best solution would be to make gdn::Format->Date overridable as many other functions, such as Plural, since setting proper locale does not do the job for some languages (it would be better to format text in different way). For instance, in russian locale-formatted string looks like, say, "Июнь 24", while proper way is "24 июня".
Gdn_Format::Date() uses strftime() which can display month in genitive case. Use token %B. However, I think that anyway need to make overridable Format::Date() function, +1 @TiGR
@S token %B does not return month in genitive case on various server configurations (quite common problem, btw, AFAIK it works better only on FreeBSD servers, all linux servers return nominative form).
The problem is that Gdn_Format::Date() calls are located not only in theme.
P.S: We can't add FreeBSD as a requirement for Vanilla, right? Then we need function override.
0
oliverradunerContributing to Vanilla since 2010Switzerland✭✭
At this point I want throw in the initial question to the discussion
How do i translate month names?
1
phreakVanillaAPP - White label iOS and Android AppMVP
Hi all,
I'm interested as well in the date change issue. Can someone hep translate "S"'s idea into something that easier to understand and implement for the time beeing?
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?
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.
0
phreakVanillaAPP - White label iOS and Android AppMVP
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 :
@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.
Comments
Most likely I found the reason, why you cannot localize Months & Days (yet): http://github.com/vanillaforums/Garden/commit/ce6c2600a98ed2a8571424edc3c74fb42e1891ed#commitcomment-98474
or manually edit necessary lines?
http://php.net/manual/en/function.setlocale.php
// Test on Linux
locale -a =>
setlocale($LocaleName. '.'. $Encoding);
// php script
$x[] = setlocale(LC_ALL, 'sk_SK'); // Fail.
huh?
http://vanillaforums.org/blog/translation-improvements-in-vanilla-2/comment-page-1/#comment-2238
Here is more information about various locale-related bugs in PHP: http://www.onphp5.com/article/22
It is the only thing to do - modify your theme
P.S: We can't add FreeBSD as a requirement for Vanilla, right? Then we need function override.
I'm interested as well in the date change issue. Can someone hep translate "S"'s idea into something that easier to understand and implement for the time beeing?
Thanx
VanillaAPP - White label iOS and Android App for Vanilla // Press Theme is ready for Vanilla 2.3+ - Check it out! // Made by VanillaSkins.com
Vanilla Forums COO [GitHub, Twitter, About.me]
Furthermore: is there a setting to change date and time format?
Does anyone have an idea?
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?
VanillaAPP - White label iOS and Android App for Vanilla // Press Theme is ready for Vanilla 2.3+ - Check it out! // Made by VanillaSkins.com
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
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.