Hi,
First, thank you very much for this software. Thank you also for the new release!!
I would like to change the date format (in french) of zenphoto but I don't know how to procede. I know that the lines which should be modified are the following :
`
function getSearchDate($format="F Y") {
if (in_context(ZP_SEARCH)) {
global $_zp_current_search;
$date = $_zp_current_search->getSearchDate();
if (empty($date)) { return ""; }
if ($date == '0000-00') { return "no date"; };
$dt = strtotime($date."-01");
return date($format, $dt);
}
return false;
}
`
- and -
`
function printAllDates($class="archive", $yearid="year", $monthid="month") {
if (!empty($class)){ $class = "class=\"$class\""; }
if (!empty($yearid)){ $yearid = "id=\"$yearid\""; }
if (!empty($monthid)){ $monthid = "id=\"$monthid\""; }
$datecount = getAllDates();
$lastyear = "";
echo "n
n";
while (list($key, $val) = each($datecount)) {
$nr++;
if ($key == '0000-00-01') {
$year = "no date";
$month = "";
} else {
$dt = date('Y-F', strtotime($key));
$year = substr($dt, 0, 4);
$month = substr($dt, 5);
}
if ($lastyear != $year) {
$lastyear = $year;
if($nr != 1) { echo "
nn";}
echo "$yearn
nnn";
}
`
In fact, I would like change the months. In example, "January" in "Janvier", "Februar" in "Février", "March" in "Mars.
Has someone an idea?
Thanks.
Sincerely,
Tom.
Comments
Edit:
`
function printAllDates($class="archive", $yearid="year", $monthid="month") {
if (!empty($class)){ $class = "class=\"$class\""; }
if (!empty($yearid)){ $yearid = "id=\"$yearid\""; }
if (!empty($monthid)){ $monthid = "id=\"$monthid\""; }
$datecount = getAllDates();
$lastyear = "";
echo "n
n";
nn";}while (list($key, $val) = each($datecount)) {
$nr++;
if ($key == '0000-00-01') {
$year = "no date";
$month = "";
} else {
$dt = date('Y-F', strtotime($key));
$year = substr($dt, 0, 4);
$month = substr($dt, 5);
}
if ($lastyear != $year) {
$lastyear = $year;
if($nr != 1) { echo "
echo "$yearn
n";- $month ($val)
n";
nnn";}
if($month === "January") { $month = "Janvier"; } // ADD IT LIKE THIS FOR ALL MONTHS
echo "
}
echo "
}`
You shouldn't then edit getSearchDate() but the your search.php around this:
`
<?php <br />
if ($_REQUEST['words'] OR $_REQUEST['date']) {
if (($total = getNumImages() + getNumAlbums()) > 0) {
if ($_REQUEST['date'])
{ $searchwords = getSearchDate();
// ADD IT LIKE THIS FOR ALL MONTHS
if(stristr($searchwords,'January')) { $searchwords = strtr($searchwords,'January', 'Janvier'); }
} else { $searchwords = getSearchWords(); }
echo "
Total matches for ".$searchwords.": $total
";?>`
However, these functions are used to get a 'month year" result for the archive page. If you are getting the English for the month, then the internationalzation of you zenphoto is not setup.
If you are looking at different data formats, then you will need to look to a different function. For instance, printImageDate() is the function that would print a date for your image in your theme. These functions also have date format parameters that you can change in your theme to be the format you desire.
Thanks for your answers!!
acrylian : thank you for your code, the first works very well! I have a problem with the second.
With :
`
if(stristr($searchwords,'January')) { $searchwords = strtr($searchwords,'February', 'Fevrier'); }
`
We get "Fevriery" and not "Fevrier". I think there is a problem with "strtr". You can view the problem here: http://lex-network.phpnet.org/paradise/index.php?p=search&date=2006-02
See you later.
`if(stristr($searchwords,'February')) { $searchwords = substr_replace($searchwords,'Fevrier',0,7);`
The last number in `substr_replace($searchwords,'Oktob',0,7)` must be the exact length of the month's english name. (and again for all months of course).
(We had made up a simpler solution for that but that currently doesn't work for me anymore...yesterday it did...)
`$fr_months = array('January' => 'Janvier', 'February' => 'Fevier', etc. );`
then take the in printAllDates `$month = $fr_months[substr($dt, 5)];`
My gallery is now in French (front office only)!
See you later and thanks for your help!