Skip to content

Commit

Permalink
fixed bug #14323: wrong / no error from setLang() [cwiedmann]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Translation2/trunk@262860 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
quipo committed Jul 17, 2008
1 parent c69e359 commit 29fa5cd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
14 changes: 10 additions & 4 deletions Container.php
Expand Up @@ -157,11 +157,14 @@ function setCharset($charset)
* *
* @param string $langID language ID * @param string $langID language ID
* *
* @return array language information * @return array|PEAR_Error language information
*/ */
function setLang($langID) function setLang($langID)
{ {
$this->getLangs(); //load available languages, if not loaded yet (ignore return value) $res = $this->getLangs(); //load available languages, if not loaded yet
if (PEAR::isError($res)) {
return $res;
}
if (!array_key_exists($langID, $this->langs)) { if (!array_key_exists($langID, $this->langs)) {
return $this->raiseError('unknown language: "'.$langID.'"', return $this->raiseError('unknown language: "'.$langID.'"',
TRANSLATION2_ERROR_UNKNOWN_LANG, TRANSLATION2_ERROR_UNKNOWN_LANG,
Expand Down Expand Up @@ -212,13 +215,16 @@ function getLangData($langID, $format = 'id')
* *
* @param string $format ['array' | 'ids' | 'names' | 'encodings'] * @param string $format ['array' | 'ids' | 'names' | 'encodings']
* *
* @return array * @return array|PEAR_Error
*/ */
function getLangs($format = 'array') function getLangs($format = 'array')
{ {
//if not cached yet, fetch langs data from the container //if not cached yet, fetch langs data from the container
if (empty($this->langs) || !count($this->langs)) { if (empty($this->langs) || !count($this->langs)) {
$this->fetchLangs(); //container-specific method $res = $this->fetchLangs(); //container-specific method
if (PEAR::isError($res)) {
return $res;
}
} }


$tmp = array(); $tmp = array();
Expand Down
4 changes: 2 additions & 2 deletions Decorator.php
Expand Up @@ -198,11 +198,11 @@ function setCharset($charset)
* *
* @param string $langID language ID * @param string $langID language ID
* *
* @return void * @return true|PEAR_Error
*/ */
function setLang($langID) function setLang($langID)
{ {
$this->translation2->setLang($langID); return $this->translation2->setLang($langID);
} }


// }}} // }}}
Expand Down
5 changes: 3 additions & 2 deletions Translation2.php
Expand Up @@ -296,7 +296,7 @@ function setCharset($charset)
* *
* @param string $langID language code (for instance, 'en' or 'it') * @param string $langID language code (for instance, 'en' or 'it')
* *
* @return void|PEAR_Error * @return true|PEAR_Error
*/ */
function setLang($langID) function setLang($langID)
{ {
Expand All @@ -305,6 +305,7 @@ function setLang($langID)
return $res; return $res;
} }
$this->lang = $res; $this->lang = $res;
return true;
} }


// }}} // }}}
Expand Down Expand Up @@ -373,7 +374,7 @@ function getLang($langID = null, $format = 'name')
* *
* @param string $format ['ids', 'names', 'array'] * @param string $format ['ids', 'names', 'array']
* *
* @return array * @return array|PEAR_Error
*/ */
function getLangs($format = 'name') function getLangs($format = 'name')
{ {
Expand Down
8 changes: 5 additions & 3 deletions package.xml
Expand Up @@ -45,8 +45,8 @@ Currently, the following decorators are provided:
<email>mike@php.net</email> <email>mike@php.net</email>
<active>yes</active> <active>yes</active>
</developer> </developer>
<date>2008-05-18</date> <date>2008-07-17</date>
<time>19:56:00</time> <time>12:20:00</time>
<version> <version>
<release>2.0.1</release> <release>2.0.1</release>
<api>2.0.1</api> <api>2.0.1</api>
Expand All @@ -57,6 +57,7 @@ Currently, the following decorators are provided:
</stability> </stability>
<license uri="http://www.debian.org/misc/bsd.license">BSD</license> <license uri="http://www.debian.org/misc/bsd.license">BSD</license>
<notes>- fixed bug #13933: undefined variable in the dataobjectsimple driver <notes>- fixed bug #13933: undefined variable in the dataobjectsimple driver
- fixed bug #14323: wrong / no error from setLang() [cwiedmann]
</notes> </notes>
<contents> <contents>
<dir name="/"> <dir name="/">
Expand Down Expand Up @@ -200,9 +201,10 @@ Currently, the following decorators are provided:
<release>stable</release> <release>stable</release>
<api>stable</api> <api>stable</api>
</stability> </stability>
<date>2008-05-18</date> <date>2008-07-17</date>
<license uri="http://www.debian.org/misc/bsd.license">BSD</license> <license uri="http://www.debian.org/misc/bsd.license">BSD</license>
<notes>- fixed bug #13933: undefined variable in the dataobjectsimple driver <notes>- fixed bug #13933: undefined variable in the dataobjectsimple driver
- fixed bug #14323: wrong / no error from setLang() [cwiedmann]
</notes> </notes>
</release> </release>
<release> <release>
Expand Down

0 comments on commit 29fa5cd

Please sign in to comment.