PHP Class Bluz\Translator\Translator

Inheritance: use trait Bluz\Common\Options
Afficher le fichier Open project: bluzphp/framework Class Usage Examples

Protected Properties

Свойство Type Description
$domain text domain
$locale string Locale
$path path to text domain files

Méthodes publiques

Méthode Description
addTextDomain ( string $domain, string $path ) : self Add text domain for gettext
setDomain ( string $domain ) : self Set domain
setLocale ( string $locale ) : self Set locale
setPath ( string $path ) : self Set path to l10n
translate ( string $message, $text ) : string Translate message
translatePlural ( string $singular, string $plural, integer $number, $text ) : string Translate plural form

Méthodes protégées

Méthode Description
initOptions ( ) : void Initialization

Method Details

addTextDomain() public méthode

Add text domain for gettext
public addTextDomain ( string $domain, string $path ) : self
$domain string of text for gettext setup
$path string on filesystem
Résultat self

initOptions() protected méthode

Initialization
protected initOptions ( ) : void
Résultat void

setDomain() public méthode

Set domain
public setDomain ( string $domain ) : self
$domain string
Résultat self

setLocale() public méthode

Set locale
public setLocale ( string $locale ) : self
$locale string
Résultat self

setPath() public méthode

Set path to l10n
public setPath ( string $path ) : self
$path string
Résultat self

translate() public static méthode

Simple example of usage equal to gettext('Message') Translator::translate('Message'); Simple replace of one or more argument(s) equal to sprintf(gettext('Message to %s'), 'Username') Translator::translate('Message to %s', 'Username');
public static translate ( string $message, $text ) : string
$message string
$text
Résultat string

translatePlural() public static méthode

Example of usage plural form + sprintf equal to sprintf(ngettext('%d comment', '%d comments', 4), 4) Translator::translatePlural('%d comment', '%d comments', 4, 4) Example of usage plural form + sprintf equal to sprintf(ngettext('%d comment', '%d comments', 4), 4, 'Topic') Translator::translatePlural('%d comment to %s', '%d comments to %s', 4, 'Topic')
public static translatePlural ( string $singular, string $plural, integer $number, $text ) : string
$singular string
$plural string
$number integer
$text
Résultat string

Property Details

$domain protected_oe property

text domain
protected $domain

$locale protected_oe property

Locale
protected string $locale
Résultat string

$path protected_oe property

path to text domain files
protected $path