PHP Class Kdyby\Translation\Translator

Author: Fabien Potencier ([email protected])
Author: Filip Procházka ([email protected])
Inheritance: extends Symfony\Component\Translation\Translator, implements ITranslator
Mostrar archivo Open project: kdyby/translation Class Usage Examples

Public Methods

Method Description
__call ( string $name, array $args ) : mixed Call to undefined method.
__callStatic ( string $name, array $args ) : mixed Call to undefined static method.
__construct ( Kdyby\Translation\IUserLocaleResolver $localeResolver, Symfony\Component\Translation\MessageSelector $selector, CatalogueCompiler $catalogueCompiler, FallbackResolver $fallbackResolver, Kdyby\Translation\IResourceLoader $loader )
__get ( string $name ) : mixed Returns property value. Do not call directly.
__isset ( string $name ) : boolean Is property defined?
__set ( string $name, mixed $value ) : void Sets value of a property. Do not call directly.
__unset ( string $name ) : void Access to undeclared property.
addLoader ( string $format, Symfony\Component\Translation\Loader\LoaderInterface $loader )
addResource ( $format, $resource, $locale, $domain = NULL )
buildWhitelistRegexp ( null | string $whitelist ) : null | string
createTemplateHelpers ( ) : TemplateHelpers
domain ( string $messagePrefix ) : ITranslator
extensionMethod ( $name, null $callback = NULL ) : callable | null Adding method to class.
getAvailableLocales ( ) : array Returns array of locales from given resources
getDefaultLocale ( ) : string
getLocale ( )
getReflection ( ) : ClassType Access to reflection.
injectPanel ( Panel $panel )
injectPsrLogger ( Psr\Log\LoggerInterface $logger = NULL )
setDefaultLocale ( string $locale ) : Translator
setFallbackLocales ( array $locales )
setLocaleWhitelist ( array $whitelist = NULL ) : Translator
trans ( $message, array $parameters = [], $domain = NULL, $locale = NULL )
transChoice ( $message, $number, array $parameters = [], $domain = NULL, $locale = NULL )
translate ( string $message, integer $count = NULL, array $parameters = [], string $domain = NULL, string $locale = NULL ) : string Translates the given string.

Protected Methods

Method Description
assertValidLocale ( string $locale ) Asserts that the locale is valid, throws an Exception if not.
computeFallbackLocales ( $locale )
getLoaders ( ) : Symfony\Component\Translation\Loader\LoaderInterface[]
loadCatalogue ( $locale )
logMissingTranslation ( string $message, string $domain, string $locale )

Private Methods

Method Description
extractMessageDomain ( string $message ) : array

Method Details

__call() public method

Call to undefined method.
public __call ( string $name, array $args ) : mixed
$name string
$args array
return mixed

__callStatic() public static method

Call to undefined static method.
public static __callStatic ( string $name, array $args ) : mixed
$name string
$args array
return mixed

__construct() public method

public __construct ( Kdyby\Translation\IUserLocaleResolver $localeResolver, Symfony\Component\Translation\MessageSelector $selector, CatalogueCompiler $catalogueCompiler, FallbackResolver $fallbackResolver, Kdyby\Translation\IResourceLoader $loader )
$localeResolver Kdyby\Translation\IUserLocaleResolver
$selector Symfony\Component\Translation\MessageSelector The message selector for pluralization
$catalogueCompiler CatalogueCompiler
$fallbackResolver FallbackResolver
$loader Kdyby\Translation\IResourceLoader

__get() public method

Returns property value. Do not call directly.
public __get ( string $name ) : mixed
$name string
return mixed

__isset() public method

Is property defined?
public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

Sets value of a property. Do not call directly.
public __set ( string $name, mixed $value ) : void
$name string
$value mixed
return void

__unset() public method

Access to undeclared property.
public __unset ( string $name ) : void
$name string
return void

addLoader() public method

public addLoader ( string $format, Symfony\Component\Translation\Loader\LoaderInterface $loader )
$format string
$loader Symfony\Component\Translation\Loader\LoaderInterface

addResource() public method

public addResource ( $format, $resource, $locale, $domain = NULL )

assertValidLocale() protected method

Asserts that the locale is valid, throws an Exception if not.
protected assertValidLocale ( string $locale )
$locale string Locale to tests

buildWhitelistRegexp() public static method

public static buildWhitelistRegexp ( null | string $whitelist ) : null | string
$whitelist null | string
return null | string

computeFallbackLocales() protected method

protected computeFallbackLocales ( $locale )

createTemplateHelpers() public method

public createTemplateHelpers ( ) : TemplateHelpers
return TemplateHelpers

domain() public method

public domain ( string $messagePrefix ) : ITranslator
$messagePrefix string
return ITranslator

extensionMethod() public static method

Adding method to class.
public static extensionMethod ( $name, null $callback = NULL ) : callable | null
$name
$callback null
return callable | null

getAvailableLocales() public method

Returns array of locales from given resources
public getAvailableLocales ( ) : array
return array

getDefaultLocale() public method

public getDefaultLocale ( ) : string
return string

getLoaders() protected method

protected getLoaders ( ) : Symfony\Component\Translation\Loader\LoaderInterface[]
return Symfony\Component\Translation\Loader\LoaderInterface[]

getLocale() public method

public getLocale ( )

getReflection() public static method

Access to reflection.
public static getReflection ( ) : ClassType
return Nette\Reflection\ClassType

injectPanel() public method

public injectPanel ( Panel $panel )
$panel Kdyby\Translation\Diagnostics\Panel

injectPsrLogger() public method

public injectPsrLogger ( Psr\Log\LoggerInterface $logger = NULL )
$logger Psr\Log\LoggerInterface

loadCatalogue() protected method

protected loadCatalogue ( $locale )

logMissingTranslation() protected method

protected logMissingTranslation ( string $message, string $domain, string $locale )
$message string
$domain string
$locale string

setDefaultLocale() public method

public setDefaultLocale ( string $locale ) : Translator
$locale string
return Translator

setFallbackLocales() public method

public setFallbackLocales ( array $locales )
$locales array

setLocaleWhitelist() public method

public setLocaleWhitelist ( array $whitelist = NULL ) : Translator
$whitelist array
return Translator

trans() public method

public trans ( $message, array $parameters = [], $domain = NULL, $locale = NULL )
$parameters array

transChoice() public method

public transChoice ( $message, $number, array $parameters = [], $domain = NULL, $locale = NULL )
$parameters array

translate() public method

Translates the given string.
public translate ( string $message, integer $count = NULL, array $parameters = [], string $domain = NULL, string $locale = NULL ) : string
$message string The message id
$count integer The number to use to find the indice of the message
$parameters array An array of parameters for the message
$domain string The domain for the message
$locale string The locale
return string