Sections

Abstract Class Phalcon\Translate\Adapter\AbstractAdapter

GitHub上のソース

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

Phalcon\Translate\Adapter

Base class for Phalcon\Translate adapters

Properties

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

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

メソッド

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

//

public function _( string $translateKey, mixed $placeholders = null ): string;

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

@param array placeholders

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

@param string value

public function offsetUnset( mixed $offset ): void;

Unsets a translation from the dictionary

public function t( string $translateKey, mixed $placeholders = null ): string;

Returns the translation string of the given key

@param array placeholders

protected function replacePlaceholders( string $translation, mixed $placeholders = null ): string;

Replaces placeholders by the values passed

Interface Phalcon\Translate\Adapter\AdapterInterface

GitHub上のソース

Namespace Phalcon\Translate\Adapter

Phalcon\Translate\AdapterInterface

Interface for Phalcon\Translate adapters

メソッド

public function exists( string $index ): bool;

Check whether is defined a translation key in the internal array

public function query( string $translateKey, mixed $placeholders = null ): string;

Returns the translation related to the given key

@param array placeholders

public function t( string $translateKey, mixed $placeholders = null ): string;

Returns the translation string of the given key

@param array placeholders

Class Phalcon\Translate\Adapter\Csv

GitHub上のソース

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

Phalcon\Translate\Adapter\Csv

Allows to define translation lists using CSV file

Properties

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

メソッド

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

Phalcon\Translate\Adapter\Csv constructor

public function exists( string $index ): bool;

Check whether is defined a translation key in the internal array

public function query( string $index, mixed $placeholders = null ): string;

Returns the translation related to the given key

Class Phalcon\Translate\Adapter\Gettext

GitHub上のソース

Namespace Phalcon\Translate\Adapter   Uses ArrayAccess, Phalcon\Translate\Exception, Phalcon\Translate\Adapter\AbstractAdapter, 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;

メソッド

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

Phalcon\Translate\Adapter\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(): string|array
public function getLocale(): string
public function nquery( string $msgid1, string $msgid2, int $count, mixed $placeholders = null, 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 $index, mixed $placeholders = null ): string;

Returns the translation related to the given key.

$translator->query("你好 %name%!", ["name" => "Phalcon"]);

@param array placeholders

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",
    ]
);
@param string array directory The directory path or an array of directories and domains
public function setDomain( mixed $domain ): string;

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

public function setLocale( int $category, string $locale ): 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, "[email protected]", "de_DE", "de", "ge");
protected function getOptionsDefault(): array;

Gets default options

protected function prepareOptions( array $options ): void;

Validator for constructor

Class Phalcon\Translate\Adapter\NativeArray

GitHub上のソース

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

Phalcon\Translate\Adapter\NativeArray

Allows to define translation lists using PHP arrays

Properties

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

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

メソッド

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

Phalcon\Translate\Adapter\NativeArray constructor

public function exists( 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 medhod will be called

public function query( string $index, mixed $placeholders = null ): string;

Returns the translation related to the given key

Class Phalcon\Translate\Exception

GitHub上のソース

Namespace Phalcon\Translate   Extends \Phalcon\Exception

Phalcon\Translate\Exception

Class for exceptions thrown by Phalcon\Translate

Class Phalcon\Translate\Interpolator\AssociativeArray

GitHub上のソース

Namespace Phalcon\Translate\Interpolator   Uses Phalcon\Translate\Interpolator\InterpolatorInterface   Implements InterpolatorInterface

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.

メソッド

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

Replaces placeholders by the values passed

Class Phalcon\Translate\Interpolator\IndexedArray

GitHub上のソース

Namespace Phalcon\Translate\Interpolator   Uses Phalcon\Translate\Interpolator\InterpolatorInterface   Implements InterpolatorInterface

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.

メソッド

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

Replaces placeholders by the values passed

Interface Phalcon\Translate\Interpolator\InterpolatorInterface

GitHub上のソース

Namespace Phalcon\Translate\Interpolator

Phalcon\Translate\InterpolatorInterface

Interface for Phalcon\Translate interpolators

メソッド

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

Replaces placeholders by the values passed

Class Phalcon\Translate\InterpolatorFactory

GitHub上のソース

Namespace Phalcon\Translate   Uses Phalcon\Factory\AbstractFactory, Phalcon\Translate\Adapter\AdapterInterface   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.

Properties

/**
 * @var array
 */
private mapper;

/**
 * @var array
 */
private services;

メソッド

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

AdapterFactory constructor.

public function newInstance( string $name ): AdapterInterface;

Create a new instance of the adapter

protected function getAdapters(): array;

//

Class Phalcon\Translate\TranslateFactory

GitHub上のソース

Namespace Phalcon\Translate   Uses Phalcon\Config\Config, Phalcon\Factory\AbstractFactory, Phalcon\Helper\Arr, Phalcon\Translate\InterpolatorFactory   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.

Properties

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

メソッド

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

AdapterFactory constructor.

public function load( mixed $config ): mixed;

Factory to create an instace from a Config object

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

Create a new instance of the adapter

protected function getAdapters(): array;

//