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).
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?
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
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •or manually edit necessary lines?
- Spam
- Abuse
- Troll
1 • Off Topic Insightful Awesome 1LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •http://php.net/manual/en/function.setlocale.php
// Test on Linux
locale -a =>
setlocale($LocaleName. '.'. $Encoding);
// php script
$x[] = setlocale(LC_ALL, 'sk_SK'); // <--- locale not set<br />$x[] = setlocale(LC_ALL, 'sk_SK.UTF-8');
var_dump($x);
* bool(false)
** string(11) "sk_SK.UTF-8"
/bootstrap.php ~ line 119:
$CurrentLocale = Gdn::Config('Garden.Locale', 'en-CA');Fail.setlocale(LC_ALL, str_replace('-', '_', $CurrentLocale));
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •huh?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •http://vanillaforums.org/blog/translation-improvements-in-vanilla-2/comment-page-1/#comment-2238
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Here is more information about various locale-related bugs in PHP: http://www.onphp5.com/article/22
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •It is the only thing to do - modify your theme
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •P.S: We can't add FreeBSD as a requirement for Vanilla, right? Then we need function override.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
1 • Off Topic Insightful Awesome LOL •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
VanillaSkins.com Themes / Custom Themes / Design & Graphics for Vanilla
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Vanilla Forums Senior Developer [GitHub, Twitter, About.me]
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Furthermore: is there a setting to change date and time format?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Does anyone have an idea? :)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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. :)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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?
VanillaSkins.com Themes / Custom Themes / Design & Graphics for Vanilla
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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 :
- Spam
- Abuse
- Troll
3 • Off Topic Insightful 3Awesome LOL •Brilliant reply
422 Real Estate Australia , now open Check it out
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •It doesn't work for me. Instead month names, show only one letter.
Anyone else tried Olivier_Chevet's instructions?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •