Change zenphoto date

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 "$yearnnnn";

}

`

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

  • localization is going to be a priority for 1.2, hopefully someone can help you out before then, but if not..it is coming.
  • acrylian Administrator, Developer
    Tom: For now I have no other idea than this quick and ugly solution:
    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";
      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
      n";
      }
      if($month === "January") { $month = "Janvier"; } // ADD IT LIKE THIS FOR ALL MONTHS
      echo "
    • $month ($val)
    • n";
      }
      echo "
    nnn";

    }`

    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

    ";

    ?>`
  • Are you calling getSearchDate() directly? If so just add a parameter to the call whith the date format you desire.

    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.
  • Hi all!

    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. ;)
  • acrylian Administrator, Developer
    You're right (although you have a typo in your expample), it's how the strtr() works. Please try this:

    `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...)
  • Another way to do this would be with an array indexed by the English month name:

    `$fr_months = array('January' => 'Janvier', 'February' => 'Fevier', etc. );`

    then take the in printAllDates `$month = $fr_months[substr($dt, 5)];`
  • Thanks acrylian and sbillard: your suggestions work very well!

    My gallery is now in French (front office only)! :D

    See you later and thanks for your help! ;)
Sign In or Register to comment.