/usr/share/php/Horde/Translation.php is in php-horde-translation 2.0.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | <?php
/**
* @package Translation
*
* Copyright 2010-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*/
/**
* Horde_Translation is the base class for any translation wrapper classes in
* libraries that want to utilize the Horde_Translation library for
* translations.
*
* @author Jan Schneider <jan@horde.org>
* @package Translation
*/
abstract class Horde_Translation
{
/**
* The translation domain, e.g. the library name, for the default gettext
* handler.
*
* @var string
*/
static protected $_domain;
/**
* The relative path to the translations for the default gettext handler.
*
* This path is relative to the
*
* @var string
*/
static protected $_directory;
/**
* The handlers providing the actual translations.
*
* @var array
*/
static protected $_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.
*/
static public function loadHandler($handlerClass)
{
if (!self::$_domain || !self::$_directory) {
throw new Horde_Translation_Exception('The domain and directory properties must be set by the class that extends Horde_Translation.');
}
self::setHandler(self::$_domain, new $handlerClass(self::$_domain, self::$_directory));
}
/**
* Assigns a translation handler object to $_handlers.
*
* Type hinting isn't used on purpose. You should extend a custom
* translation handler passed here from the Horde_Translation interface,
* but technically it's sufficient if you provide the API of that
* interface.
*
* @param string $domain The translation domain.
* @param Horde_Translation_Handler $handler An object implementing the
* Horde_Translation_Handler
* interface.
*/
static public function setHandler($domain, $handler)
{
self::$_handlers[$domain] = $handler;
}
/**
* Returns the translation of a message.
*
* @var string $message The string to translate.
*
* @return string The string translation, or the original string if no
* translation exists.
*/
static public function t($message)
{
if (!isset(self::$_handlers[self::$_domain])) {
self::loadHandler('Horde_Translation_Handler_Gettext');
}
return self::$_handlers[self::$_domain]->t($message);
}
/**
* Returns the plural translation of a message.
*
* @param string $singular The singular version to translate.
* @param string $plural The plural version to translate.
* @param integer $number The number that determines singular vs. plural.
*
* @return string The string translation, or the original string if no
* translation exists.
*/
static public function ngettext($singular, $plural, $number)
{
if (!isset(self::$_handlers[self::$_domain])) {
self::loadHandler('Horde_Translation_Handler_Gettext');
}
return self::$_handlers[self::$_domain]->ngettext($singular, $plural, $number);
}
}
|