mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 17:18:51 +02:00
Improved error handling and localization
SVN:trunk[437]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user