Sections

Abstract Class Phalcon\Translate\Adapter\AbstractAdapter

Source sur GitHub

Namespace Phalcon\Translate\Adapter   Uses Phalcon\Support\Helper\Arr\Get, Phalcon\Translate\Exception, Phalcon\Translate\InterpolatorFactory   Implements AdapterInterface

Class AbstractAdapter

Properties

/**
 * @var string
 */
protected defaultInterpolator = ;

/**
    * @var InterpolatorFactory
    */
protected interpolatorFactory;

Méthodes

public function __construct( InterpolatorFactory $interpolator, array $options = [] );

AbstractAdapter constructor.

public function _( string $translateKey, array $placeholders = [] ): string;

Returns the translation string of the given key (alias of method ‘t’)

public function offsetExists( mixed $translateKey ): bool;

Check whether a translation key exists

public function offsetGet( mixed $translateKey ): mixed;

Returns the translation related to the given key

public function offsetSet( mixed $offset, mixed $value ): void;

Sets a translation value

public function offsetUnset( mixed $offset ): void;

Unsets a translation from the dictionary

public function t( string $translateKey, array $placeholders = [] ): string;

Returns the translation string of the given key

protected function replacePlaceholders( string $translation, array $placeholders = [] ): string;

Replaces placeholders by the values passed

Interface Phalcon\Translate\Adapter\AdapterInterface

Source sur GitHub

Namespace Phalcon\Translate\Adapter

Phalcon\Translate\Adapter\AdapterInterface

Interface for Phalcon\Translate adapters

Méthodes

public function has( string $index ): bool;

Check whether is defined a translation key in the internal array

public function query( string $translateKey, array $placeholders = [] ): string;

Returns the translation related to the given key

public function t( string $translateKey, array $placeholders = [] ): string;

Returns the translation string of the given key

Class Phalcon\Translate\Adapter\Csv

Source sur GitHub

Namespace Phalcon\Translate\Adapter   Uses ArrayAccess, Phalcon\Translate\Exception, Phalcon\Translate\InterpolatorFactory   Extends AbstractAdapter   Implements ArrayAccess

Class Csv

Properties

/**
 * @var array
 */
protected translate;

Méthodes

public function __construct( InterpolatorFactory $interpolator, array $options );

Csv constructor.

public function exists( string $index ): bool;

Check whether is defined a translation key in the internal array

public function has( string $index ): bool;

Check whether is defined a translation key in the internal array

public function query( string $translateKey, array $placeholders = [] ): string;

Returns the translation related to the given key

public function toArray(): array;

Returns the internal array

protected function phpFopen( string $filename, string $mode );

@todo to be removed when we get traits

Class Phalcon\Translate\Adapter\Gettext

Source sur GitHub

Namespace Phalcon\Translate\Adapter   Uses ArrayAccess, Phalcon\Translate\Exception, Phalcon\Translate\InterpolatorFactory   Extends AbstractAdapter   Implements ArrayAccess

Phalcon\Translate\Adapter\Gettext

use Phalcon\Translate\Adapter\Gettext;

$adapter = new Gettext(
    [
        "locale"        => "de_DE.UTF-8",
        "defaultDomain" => "translations",
        "directory"     => "/path/to/application/locales",
        "category"      => LC_MESSAGES,
    ]
);

Allows translate using gettext

Properties

/**
 * @var int
 */
protected category;

/**
 * @var string
 */
protected defaultDomain;

/**
 * @var string|array
 */
protected directory;

/**
 * @var string
 */
protected locale;

Méthodes

public function __construct( InterpolatorFactory $interpolator, array $options );

Gettext constructor.

public function exists( string $index ): bool;

Check whether is defined a translation key in the internal array

public function getCategory(): int;
public function getDefaultDomain(): string;
public function getDirectory(): array | string;
public function getLocale(): string;
public function has( string $index ): bool;

Check whether is defined a translation key in the internal array

public function nquery( string $msgid1, string $msgid2, int $count, array $placeholders = [], string $domain = null ): string;

The plural version of gettext(). Some languages have more than one form for plural messages dependent on the count.

public function query( string $translateKey, array $placeholders = [] ): string;

Returns the translation related to the given key.

$translator->query("你好 %name%!", ["name" => "Phalcon"]);
public function resetDomain(): string;

Sets the default domain

public function setDefaultDomain( string $domain ): void;

Sets the domain default to search within when calls are made to gettext()

public function setDirectory( mixed $directory ): void;

Sets the path for a domain

// Set the directory path
$gettext->setDirectory("/path/to/the/messages");

// Set the domains and directories path
$gettext->setDirectory(
    [
        "messages" => "/path/to/the/messages",
        "another"  => "/path/to/the/another",
    ]
);
public function setDomain( string $domain = null ): string;

Changes the current domain (i.e. the translation file)

public function setLocale( int $category, array $localeArray = [] ): string | bool;

Sets locale information

// Set locale to Dutch
$gettext->setLocale(LC_ALL, "nl_NL");

// Try different possible locale names for German
$gettext->setLocale(LC_ALL, "de_DE@euro", "de_DE", "de", "ge");
protected function getOptionsDefault(): array;

Gets default options

protected function phpFunctionExists( string $name ): bool;

@todo to be removed when we get traits

protected function prepareOptions( array $options ): void;

Validator for constructor

Class Phalcon\Translate\Adapter\NativeArray

Source sur GitHub

Namespace Phalcon\Translate\Adapter   Uses ArrayAccess, Phalcon\Translate\Exception, Phalcon\Translate\InterpolatorFactory   Extends AbstractAdapter   Implements ArrayAccess

Class NativeArray

Defines translation lists using PHP arrays

Properties

/**
 * @var array
 */
private translate;

/**
 * @var bool
 */
private triggerError = false;

Méthodes

public function __construct( InterpolatorFactory $interpolator, array $options );

NativeArray constructor.

public function exists( string $index ): bool;

Check whether is defined a translation key in the internal array

public function has( string $index ): bool;

Check whether is defined a translation key in the internal array

public function notFound( string $index ): string;

Whenever a key is not found this method will be called

public function query( string $translateKey, array $placeholders = [] ): string;

Returns the translation related to the given key

public function toArray(): array;

Returns the internal array

Class Phalcon\Translate\Exception

Source sur GitHub

Namespace Phalcon\Translate   Extends \Exception

Phalcon\Translate\Exception

Class for exceptions thrown by Phalcon\Translate

Class Phalcon\Translate\Interpolator\AssociativeArray

Source sur GitHub

Namespace Phalcon\Translate\Interpolator   Uses Phalcon\Support\Helper\Str\Interpolate   Implements InterpolatorInterface

Class AssociativeArray

@package Phalcon\Translate\Interpolator

Méthodes

public function replacePlaceholders( string $translation, array $placeholders = [] ): string;

Replaces placeholders by the values passed

Class Phalcon\Translate\Interpolator\IndexedArray

Source sur GitHub

Namespace Phalcon\Translate\Interpolator   Implements InterpolatorInterface

Class IndexedArray

@package Phalcon\Translate\Interpolator

Méthodes

public function replacePlaceholders( string $translation, array $placeholders = [] ): string;

Replaces placeholders by the values passed

Interface Phalcon\Translate\Interpolator\InterpolatorInterface

Source sur GitHub

Namespace Phalcon\Translate\Interpolator

Phalcon\Translate\InterpolatorInterface

Interface for Phalcon\Translate interpolators

Méthodes

public function replacePlaceholders( string $translation, array $placeholders = [] ): string;

Replaces placeholders by the values passed

Class Phalcon\Translate\InterpolatorFactory

Source sur GitHub

Namespace Phalcon\Translate   Uses Phalcon\Factory\AbstractFactory, Phalcon\Translate\Interpolator\InterpolatorInterface   Extends AbstractFactory

This file is part of the Phalcon Framework.

(c) Phalcon Team [email protected]

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Méthodes

public function __construct( array $services = [] );

InterpolatorFactor constructor.

public function newInstance( string $name ): InterpolatorInterface;

Create a new instance of the adapter

protected function getExceptionClass(): string;
protected function getServices(): array;

Returns the available adapters

Class Phalcon\Translate\TranslateFactory

Source sur GitHub

Namespace Phalcon\Translate   Uses Phalcon\Config\ConfigInterface, Phalcon\Factory\AbstractFactory, Phalcon\Translate\Adapter\AdapterInterface   Extends AbstractFactory

Class TranslateFactory

Properties

/**
 * @var InterpolatorFactory
 */
private interpolator;

Méthodes

public function __construct( InterpolatorFactory $interpolator, array $services = [] );

AdapterFactory constructor.

public function load( mixed $config ): AdapterInterface;

Factory to create an instance from a Config object

public function newInstance( string $name, array $options = [] ): AdapterInterface;

Create a new instance of the adapter

protected function getExceptionClass(): string;
protected function getServices(): array;

Returns the available adapters