cvs: pear /Translation2/Decorator UTF8.php

From: Date: Wed, 17 Mar 2004 14:44:20 +0000
Subject: cvs: pear /Translation2/Decorator UTF8.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-17481@lists.php.net to get a copy of this message
quipo Wed Mar 17 09:44:20 2004 EDT Added files: /pear/Translation2/Decorator UTF8.php Log: new UTF-8 decorator http://cvs.php.net/co.php/pear/Translation2/Decorator/UTF8.php?r=1.1&p=1 Index: pear/Translation2/Decorator/UTF8.php +++ pear/Translation2/Decorator/UTF8.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2004 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 3.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/3_0.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Lorenzo Alberton <l dot alberton at quipo dot it> | // +----------------------------------------------------------------------+ // // $Id: UTF8.php,v 1.1 2004/03/17 14:44:19 quipo Exp $ // /** * @package Translation2 * @version $Id: UTF8.php,v 1.1 2004/03/17 14:44:19 quipo Exp $ */ /** * Load Translation2 decorator base class */ require_once 'Translation2'.DIRECTORY_SEPARATOR.'Decorator.php'; /** * Decorator to convert UTF-8 strings to ISO-8859-1 * @package Translation2 */ class Translation2_Decorator_UTF8 extends Translation2_Decorator { // {{{ get() /** * Get translated string * * If the string is empty, check the fallback language; if * the latter is empty too, then return the $defaultText. * * @param string $stringID * @param string $pageID * @param string $langID * @param string $defaultText Text to display when the strings in both * the default and the fallback lang are empty * @return string */ function get($stringID, $pageID=TRANSLATION2_DEFAULT_PAGEID, $langID=null, $defaultText=null) { $str = $this->translation2->get($stringID, $pageID, $langID); if (!empty($str)) { $str = utf8_decode($str); //decodes an UTF-8 string to ISO-8859-1 } return $str; } // }}} // {{{ getPage() /** * Same as getRawPage, but resort to fallback language and * replace parameters when needed * * @param string $pageID * @param string $langID * @return array */ function getPage($pageID=TRANSLATION2_DEFAULT_PAGEID, $langID=null) { $data = $this->translation2->getPage($pageID, $langID); foreach ($data as $key => $val) { if (!empty($val)) { $data[$key] = utf8_decode($val); } } return $data; } // }}} } ?>

« previous php.pear.cvs (#17481) next »