Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.4

Bug #6410 Various fixes to gettext backend error handling
Submitted: 2006-01-04 01:48 UTC Modified: 2006-01-07 11:44 UTC
From: alan_k Assigned: quipo
Status: Closed Package: Translation2
PHP Version: Irrelevant OS: all
Roadmaps: (Not assigned)    
Subscription  


 [2006-01-04 01:48 UTC] alan_k
Description: ------------ diff -pur Translation2/Container/gettext.php Translation2.bak/Container/gettext.php --- Translation2/Container/gettext.php 2005-12-30 17:08:30.000000000 +0800 +++ Translation2.bak/Container/gettext.php 2005-12-30 17:07:48.000000000 +0800 @@ -242,7 +242,7 @@ class Translation2_Container_gettext ext return $this->raiseError(sprintf( '%s [%s on line %d]', $e->getMessage(), __FILE__, __LINE__ ), - TRANSLATION2_ERROR + TRANSLATION2_ERROR, PEAR_ERROR_RETURN ); } $this->_switchLang($oldLang); @@ -250,7 +250,7 @@ class Translation2_Container_gettext ext 'Cannot find file "%s" [%s on line %d]', $file, __FILE__, __LINE__ ), - TRANSLATION2_ERROR_CANNOT_FIND_FILE + TRANSLATION2_ERROR_CANNOT_FIND_FILE, PEAR_ERROR_RETURN ); } @@ -288,7 +288,13 @@ class Translation2_Container_gettext ext } // use File_Gettext - $page = $this->getPage($pageID, $langID); + if (PEAR::isError($page = $this->getPage($pageID, $langID))) { + if ($page->getCode() == TRANSLATION2_ERROR_CANNOT_FIND_FILE) { + $page = array(); + } else { + return $this->raiseError($page->getMessage(), $page->getCode()); + } + } // return original string if there's no translation available if (isset($page[$stringID]) && strlen($page[$stringID])) {

Comments

 [2006-01-06 04:13 UTC] ivanwyc at gmail dot com
Revised (not refreshing caches for pages that don't have gt file yet) diff -pur Translation2/Admin/Container/gettext.php Translation2.new/Admin/Container/gettext.php --- Translation2/Admin/Container/gettext.php 2006-01-06 16:55:40.000000000 +0800 +++ Translation2.new/Admin/Container/gettext.php 2006-01-06 17:03:53.000000000 +0800 @@ -408,10 +408,10 @@ class Translation2_Admin_Container_gette if (PEAR::isError($e = $gtFile->save($file))) { return $e; } - } - //refresh cache - $this->cachedDomains[$lang][$pageID] = $gtFile->strings; + //refresh cache + $this->cachedDomains[$lang][$pageID] = $gtFile->strings; + } } } diff -pur Translation2/Container/gettext.php Translation2.new/Container/gettext.php --- Translation2/Container/gettext.php 2006-01-06 16:55:40.000000000 +0800 +++ Translation2.new/Container/gettext.php 2006-01-06 17:03:15.000000000 +0800 @@ -226,7 +226,7 @@ class Translation2_Container_gettext ext 'file "%s" [%s on line %d]', $pageID, $this->options['domains_path_file'], __FILE__, __LINE__ ), - TRANSLATION2_ERROR_DOMAIN_NOT_SET + TRANSLATION2_ERROR_DOMAIN_NOT_SET, PEAR_ERROR_RETURN ); } @@ -242,7 +242,7 @@ class Translation2_Container_gettext ext return $this->raiseError(sprintf( '%s [%s on line %d]', $e->getMessage(), __FILE__, __LINE__ ), - TRANSLATION2_ERROR + TRANSLATION2_ERROR, PEAR_ERROR_RETURN ); } $this->_switchLang($oldLang); @@ -250,7 +250,7 @@ class Translation2_Container_gettext ext 'Cannot find file "%s" [%s on line %d]', $file, __FILE__, __LINE__ ), - TRANSLATION2_ERROR_CANNOT_FIND_FILE + TRANSLATION2_ERROR_CANNOT_FIND_FILE, PEAR_ERROR_RETURN ); } @@ -288,7 +288,13 @@ class Translation2_Container_gettext ext } // use File_Gettext - $page = $this->getPage($pageID, $langID); + if (PEAR::isError($page = $this->getPage($pageID, $langID))) { + if ($page->getCode() == TRANSLATION2_ERROR_CANNOT_FIND_FILE) { + $page = array(); + } else { + return $this->raiseError($page->getMessage(), $page->getCode()); + } + } // return original string if there's no translation available if (isset($page[$stringID]) && strlen($page[$stringID])) {
 [2006-01-07 11:44 UTC] quipo
Committed to CVS. Thanks for your patches.