You are here: Re: Translating output of PHP functions « PHP Language « IT news, forums, messages
Re: Translating output of PHP functions

Posted by Marc Nadeau on 09/29/98 11:29

talthen.z-serwera.o2@nospam.pl a écrit:

> "Jochem" <jdonkers@gmail.com>
>> The main issue is to translate things like "Tuesday, 11 October 2005"
>> into Danish (or any other language for that matter).
>
> Prepare tables like:
> Day array=(DanishNameOfDay1, DanishNameOfDay2...)
> Month array=(DanishNameofMonth1...)
> then get the date in format 01-28-08-2005 exploded into 4 variables:
> daynum,day, month,year.
> Then get the proper values from the arrays:
> DanishDate=$Day[$daynum]."-".$day."-".$Month[$month]...
>
> Regards,
> Talthen

I wrote this function for a french localisation project; should be easy to
translate. The whole librairy is copyrighted Marc Nadeau (me), 2005 and is
released unther the GNU Public Licence (GPL).

// $dateStandard means AAAA-MM-JJ format
function retournerDateTextuelle($dateStandard){

$annee = substr($dateStandard,0,4);
$mois = substr($dateStandard,5,2);
$jour = substr($dateStandard,8,2);

$moisNom['01'] = 'janvier';
$moisNom['02'] = 'f&eacute;vrier';
$moisNom['03'] = 'mars';
$moisNom['04'] = 'avril';
$moisNom['05'] = 'mai';
$moisNom['06'] = 'juin';
$moisNom['07'] = 'juillet';
$moisNom['08'] = 'ao&ucirc;t';
$moisNom['09'] = 'septembre';
$moisNom['10'] = 'octobre';
$moisNom['11'] = 'novembre';
$moisNom['12'] = 'd&eacute;cembre';

$moisTexte = $moisNom[$mois];

$dateFormatee = "$jour $moisTexte $annee";

// eliminate leading zeroes
if(substr($dateFormatee, 0, 1) == '0'){
$dateFormatee = substr($dateFormatee, 1);
}

return $dateFormatee;
}

Could be shortened or optimized but i like the clarity.


Hope that helps.



--
Cogito ergo sum... et tralala
Marc Nadeau, webmestre, La Pagerie, http://www.pagerie.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация