Improved error handling and localization

SVN:trunk[437]
This commit is contained in:
Romain Quetiez
2010-06-07 14:28:42 +00:00
parent dc2430332a
commit d3ffa21943
3 changed files with 23 additions and 9 deletions

View File

@@ -101,6 +101,11 @@ class Dict
{
// Attempt to find the string in the user language
//
if (!array_key_exists(self::$m_sCurrentLanguage, self::$m_aData))
{
// It may happen, when something happens before the dictionnaries get loaded
return $sStringCode;
}
$aCurrentDictionary = self::$m_aData[self::$m_sCurrentLanguage];
if (array_key_exists($sStringCode, $aCurrentDictionary))
{
@@ -140,8 +145,14 @@ class Dict
public static function Format($sFormatCode /*, ... arguments ....*/)
{
$sLocalizedFormat = self::S($sFormatCode);
$aArguments = func_get_args();
if ($sLocalizedFormat == $sFormatCode)
{
// Make sure the information will be displayed (ex: an error occuring before the dictionary gets loaded)
return $sFormatCode.' - '.implode(', ', $aArguments);
}
array_shift($aArguments);
return vsprintf($sLocalizedFormat, $aArguments);
}

View File

@@ -2935,6 +2935,15 @@ abstract class MetaModel
self::$m_bLogWebService = false;
}
// Note: load the dictionary as soon as possible, because it might be
// needed when some error occur
foreach ($oConfig->GetDictionaries() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'dictionaries', $sToInclude);
}
// Set the language... after the dictionaries have been loaded!
Dict::SetDefaultLanguage($oConfig->GetDefaultLanguage());
foreach ($oConfig->GetAppModules() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'application', $sToInclude);
@@ -2947,12 +2956,6 @@ abstract class MetaModel
{
self::Plugin($sConfigFile, 'addons', $sToInclude);
}
foreach ($oConfig->GetDictionaries() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'dictionaries', $sToInclude);
}
// Set the language... after the dictionaries have been loaded!
Dict::SetDefaultLanguage($oConfig->GetDefaultLanguage());
$sServer = $oConfig->GetDBHost();
$sUser = $oConfig->GetDBUser();

View File

@@ -1306,7 +1306,7 @@ catch(CoreException $e)
if (MetaModel::IsLogEnabledIssue())
{
if (class_exists('EventIssue'))
if (MetaModel::IsValidClass('EventIssue'))
{
$oLog = new EventIssue();
@@ -1335,7 +1335,7 @@ catch(Exception $e)
if (MetaModel::IsLogEnabledIssue())
{
if (class_exists('EventIssue'))
if (MetaModel::IsValidClass('EventIssue'))
{
$oLog = new EventIssue();