AbstractTranslation
in package
implements
Translation
Horde_Translation is the base class for any translation wrapper classes in libraries that want to utilize the Horde_Translation library for translations.
Tags
Interfaces, Classes, Traits and Enums
- Translation
- Horde_Translation is the base class for any translation wrapper classes in libraries that want to utilize the Horde_Translation library for translations.
Table of Contents
- $directory : string
- The relative path to the translations for the default gettext handler.
- $domain : string
- The translation domain, e.g. the library name, for the default gettext handler.
- $handlers : array<string|int, mixed>
- The handlers providing the actual translations.
- loadHandler() : void
- Loads a translation handler class pointing to the library's translations and assigns it to $handler.
- ngettext() : string
- Returns the plural translation of a message.
- r() : 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()).
- setHandler() : void
- Assigns a translation handler object to $handlers.
- t() : string
- Returns the translation of a message.
Properties
$directory
The relative path to the translations for the default gettext handler.
protected
static string
$directory
$domain
The translation domain, e.g. the library name, for the default gettext handler.
protected
static string
$domain
$handlers
The handlers providing the actual translations.
protected
static array<string|int, mixed>
$handlers
= []
Methods
loadHandler()
Loads a translation handler class pointing to the library's translations and assigns it to $handler.
public
static loadHandler(string $handlerClass) : void
Parameters
- $handlerClass : string
-
The name of a class implementing the Horde_Translation_Handler interface.
Tags
Return values
void —ngettext()
Returns the plural translation of a message.
public
static ngettext(string $singular, string $plural, int $number) : string
Parameters
- $singular : string
-
The singular version to translate.
- $plural : string
-
The plural version to translate.
- $number : int
-
The number that determines singular vs. plural.
Return values
string —The string translation, or the original string if no translation exists.
r()
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()).
public
static r(string $message) : string
Parameters
- $message : string
-
The raw string to mark for translation.
Tags
Return values
string —The raw string.
setHandler()
Assigns a translation handler object to $handlers.
public
static setHandler(string $domain, Handler $handler) : void
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
- $domain : string
-
The translation domain.
- $handler : Handler
-
An object implementing the Horde_Translation_Handler interface.
Return values
void —t()
Returns the translation of a message.
public
static t(string $message) : string
Parameters
- $message : string
-
The string to translate.
Return values
string —The string translation, or the original string if no translation exists.