Created
August 4, 2014 20:23
-
-
Save slusarz/8e6c0bc23676a81df392 to your computer and use it in GitHub Desktop.
Translation Autoconfiguration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Horde_Translation_Autoconfigure extends Horde_Translation | |
{ | |
/** | |
*/ | |
static public function loadHandler($handlerClass) | |
{ | |
if (!isset(self::$_directory)) { | |
$a = new ReflectionClass(get_called_class()); | |
$dir = dirname($a->getFilename()); | |
$subdir = substr_count(self::$_domain, '_'); | |
$dirs = array( | |
/* PEAR */ | |
$dir . str_repeat('/..', $subdir + 1) . '/data/' . self::$_domai | |
n . '/locale', | |
/* Composer */ | |
$dir . str_repeat('/..', $subdir) . '/data/locale', | |
/* Source directory */ | |
$dir . str_repeat('/..', $subdir + 1) . '/locale' | |
); | |
foreach ($dirs as $val) { | |
if (file_exists($val)) { | |
self::$_directory = realpath($val); | |
break; | |
} | |
} | |
} | |
parent::loadHandler($handlerClass); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Horde_Foo_Translation extends Horde_Translation_Autoconfigure | |
{ | |
static protected $_domain = "Horde_Foo"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment