Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
Translation

Functions

static array _getSearchDirectories ()
 Get potential locations for the locale directory.
 
static boolean string _searchLocaleDirectory ()
 Search for the locale directory for different installations methods (eg: PEAR, Composer).
 
static loadHandler ($handlerClass)
 Loads a translation handler class pointing to the library's translations and assigns it to $_handler.
 
static ngettext ($singular, $plural, $number)
 Returns the plural translation of a message.
 
static r ($message)
 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()).
 
static setHandler ($domain, $handler)
 Assigns a translation handler object to $_handlers.
 
static string t ($message)
 Returns the translation of a message.
 

Variables

static string $_directory
 The relative path to the translations for the default gettext handler.
 
static array $_handlers = array()
 The handlers providing the actual translations.
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 
*See the enclosed file LICENSE for license information(LGPL). If you *did not receive this file see http
 

Detailed Description

Function Documentation

◆ _getSearchDirectories()

static array _getSearchDirectories ( )
staticprotected

Get potential locations for the locale directory.

List of directories

◆ _searchLocaleDirectory()

static boolean string _searchLocaleDirectory ( )
staticprotected

Search for the locale directory for different installations methods (eg: PEAR, Composer).

The directory if found, or false when no valid directory is found

◆ loadHandler()

static loadHandler ( $handlerClass)
static

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

Parameters
string$handlerClassThe name of a class implementing the Horde_Translation_Handler interface.

◆ ngettext()

static ngettext ( $singular,
$plural,
$number )
static

Returns the plural translation of a message.

Parameters
string$singularThe singular version to translate.
string$pluralThe plural version to translate.
integer$numberThe number that determines singular vs. plural.
Return values
stringThe string translation, or the original string if no translation exists.

◆ r()

static r ( $message)
static

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()).

Since
2.1.0
Parameters
string$messageThe raw string to mark for translation.
Return values
stringThe raw string.

◆ setHandler()

static setHandler ( $domain,
$handler )
static

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$domainThe translation domain.
Horde_Translation_Handler$handlerAn object implementing the Horde_Translation_Handler interface.

◆ t()

static string t ( $message)
static

Returns the translation of a message.

$message The string to translate.

Return values
stringThe string translation, or the original string if no translation exists.