AbstractAdapter

Abstract adapter for recognizing files with translations.

package

Default

Methods

Initialize the adapter.

__construct(string $dir, string|null $locale = null) 

Arguments

$dir

string

Directory where are located files with translation

$locale

string|null

Name of used locale

Return a char on the the given position or null if the posion isn't exists in the string.

charAt(string $str, integer $pos) : string|null

Arguments

$str

string

String where is searched the char

$pos

integer

Position of the searched char

Response

string|null

Return a name of default locale.

getDefaultLocale() : string

Response

string

Return a directory where are located files with translation.

getDir() : string

Response

string

Return an extension of recognized files with translations.

getExtension() : string

Response

string

Return a name of used locale.

getLocale() : string

Response

string

Load a file with translations.

loadFile(boolean $defaultLocale = false) 
Throws
\Dotpay\Exception\Locale\FileNotFoundException

Thrown when a file with translations isn't found

Arguments

$defaultLocale

boolean

A flag if the dafault locale is used

Read file and parse its content for using as a source of translations.

readFile(string $filename) 
abstract

Arguments

$filename

string

Name of file with translations

Set a name of default locale.

setDefaultLocale(string $defaultLocale) 
static

Arguments

$defaultLocale

string

Name of default locale

Set a directory where are located files with translation.

setDir(string $dir) : \Dotpay\Locale\Adapter\AbstractAdapter

Arguments

$dir

string

Directory where are located files with translation

Response

\Dotpay\Locale\Adapter\AbstractAdapter

Set a name of used locale.

setLocale(string $locale) : \Dotpay\Locale\Adapter\AbstractAdapter

Arguments

$locale

string

Name of used locale

Response

\Dotpay\Locale\Adapter\AbstractAdapter

Return translated input string.

translate(string $sentence) 
abstract

Arguments

$sentence

string

Input sentence to translate

Properties

Directory where are located files with translation

dir : string
var

Directory where are located files with translation

Type(s)

string

Name of used locale, for example pl_PL, en_US

locale : string
var

Name of used locale, for example pl_PL, en_US

Type(s)

string

Extension of files recognized by the concrete instance of adapter

extension : string
var

Extension of files recognized by the concrete instance of adapter

Type(s)

string

Name of default locale which is used if the given locale is not found

defaultLocale : string
static
var

Name of default locale which is used if the given locale is not found

Type(s)

string

Flag if content of the adapter is loaded

loaded : boolean
var

Flag if content of the adapter is loaded

Type(s)

boolean