\Horde_Translation

Horde_Translation is the base class for any translation wrapper classes in libraries that want to utilize the Horde_Translation library for translations.

Summary

Methods
Properties
Constants
loadHandler()
setHandler()
t()
ngettext()
r()
No public properties found
No constants found
No protected methods found
$_domain
$_directory
$_handlers
N/A
No private methods found
No private properties found
N/A

Properties

$_domain

$_domain : string

The translation domain, e.g. the library name, for the default gettext handler.

Type

string

$_directory

$_directory : string

The relative path to the translations for the default gettext handler.

Type

string

$_handlers

$_handlers : array

The handlers providing the actual translations.

Type

array

Methods

loadHandler()

loadHandler(string  $handlerClass) 

Loads a translation handler class pointing to the library's translations and assigns it to $_handler.

Parameters

string $handlerClass

The name of a class implementing the Horde_Translation_Handler interface.

setHandler()

setHandler(string  $domain, \Horde_Translation_Handler  $handler) 

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.

Parameters

string $domain

The translation domain.

\Horde_Translation_Handler $handler

An object implementing the Horde_Translation_Handler interface.

t()

t(  $message) : string

Returns the translation of a message.

Parameters

$message

Returns

string —

The string translation, or the original string if no translation exists.

ngettext()

ngettext(string  $singular, string  $plural, integer  $number) : string

Returns the plural translation of a message.

Parameters

string $singular

The singular version to translate.

string $plural

The plural version to translate.

integer $number

The number that determines singular vs. plural.

Returns

string —

The string translation, or the original string if no translation exists.

r()

r(string  $message) : string

Allows a gettext string to be defined and recognized as a string by the horde translation utilities, but no translation is actually performed (raw gettext = r()).

Parameters

string $message

The raw string to mark for translation.

Returns

string —

The raw string.