<?php
abstract class Horde_Translation
{
/**
* The translation domain, e.g. the library name, for the default gettext
* handler.
*
* @var string
*/
protected static $_domain;
/**
* The relative path to the translations for the default gettext handler.
*
* @var string
*/
protected static $_directory;
/**
* The handlers providing the actual translations.
*
* @var array
*/
protected static $_handlers = array();
/**
* Loads a translation handler class pointing to the library's translations
* and assigns it to $_handler.
*
* @param string $handlerClass The name of a class implementing the
* Horde_Translation_Handler interface.
*/
public static function loadHandler($handlerClass)
{
if (!static::$_domain || !static::$_directory) {
throw new Exception('The domain and directory properties must be set by the class that extends Horde_Translation.');
}
echo "Success";
}
public static function t($message)
{
if (!isset(static::$_handlers[static::$_domain])) {
static::loadHandler('Horde_Translation_Handler_Gettext');
}
return static::$_handlers[static::$_domain]->t($message);
}
}
abstract class Horde_Translation_Autodetect extends Horde_Translation
{
/**
* The absolute PEAR path to the translations for the default gettext handler.
*
* This value is automatically set by PEAR Replace Tasks.
*
* @var string
*/
protected static $_pearDirectory;
/**
* Auto detects the locale directory location.
*
* @param string $handlerClass The name of a class implementing the
* Horde_Translation_Handler interface.
*/
public static function loadHandler($handlerClass)
{
if (!static::$_domain) {
throw new Exception('The domain property must be set by the class that extends Horde_Translation_Autodetect.');
}
$directory = '/tmp';
if (!$directory) {
throw new Exception(sprintf('Could not found find any locale directory for %s domain.', static::$_domain));
}
static::$_directory = $directory;
parent::loadHandler($handlerClass);
}
}
class Horde_Core_Translation extends Horde_Translation_Autodetect
{
/**
* The translation domain
*
* @var string
*/
protected static $_domain = 'Horde_Core';
/**
* The absolute PEAR path to the translations for the default gettext handler.
*
* @var string
*/
protected static $_pearDirectory = '@data_dir@';
}
Horde_Core_Translation::t("A fatal error has occurred");
Success
Warning: Undefined array key "Horde_Core" in /in/mBYtJ on line 45
Fatal error: Uncaught Error: Call to a member function t() on null in /in/mBYtJ:45
Stack trace:
#0 /in/mBYtJ(100): Horde_Translation::t('A fatal error h...')
#1 {main}
thrown in /in/mBYtJ on line 45
Process exited with code 255.
Success
Notice: Undefined index: Horde_Core in /in/mBYtJ on line 45
Fatal error: Uncaught Error: Call to a member function t() on null in /in/mBYtJ:45
Stack trace:
#0 /in/mBYtJ(100): Horde_Translation::t('A fatal error h...')
#1 {main}
thrown in /in/mBYtJ on line 45
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Success
Fatal error: Uncaught Error: Call to a member function t() on null in /in/mBYtJ:45
Stack trace:
#0 /in/mBYtJ(100): Horde_Translation::t('A fatal error h...')
#1 {main}
thrown in /in/mBYtJ on line 45
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Success
Notice: Undefined index: Horde_Core in /in/mBYtJ on line 45
Fatal error: Call to a member function t() on null in /in/mBYtJ on line 45
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Success
Notice: Undefined index: Horde_Core in /in/mBYtJ on line 45
Fatal error: Call to a member function t() on a non-object in /in/mBYtJ on line 45
Process exited with code 255.