Using translations

Date_HumanDiff ships a number of translations that provide localized messages. Version 0.4.0 comes with German (de), Greek (el) and Persian (fa) translations.

The setLocale method accepts locale names (de_AT, en_US) as well as ISO 639-1 two-letter language codes (de, fr, en). If the combination of language code + country code does not match, the language code alone is tried. If that also fails, the english variant is used.

Using the German translation

<?php
require_once 'Date/HumanDiff.php';
$dh = new Date_HumanDiff();
$dh->setLocale('de_DE');
echo 
$dh->get(time() - 60) . "\n";
//prints out "vor 5 Minuten"
?>