CodeIgniter v4.5 API

MockLanguage extends Language
in package

Handle system messages and localization.

Locale-based, built on top of PHP internationalization.

Table of Contents

Properties

$data  : mixed
Stores the data that should be returned by the 'requireFile()' method.
$intlSupport  : bool
Boolean value whether the intl libraries exist on the system.
$language  : array<string|int, mixed>
Stores the retrieved language lines from files for faster retrieval on second use.
$loadedFiles  : array<string|int, mixed>
Stores filenames that have been loaded so that we don't load them again.
$locale  : string
The current language/locale to work with.

Methods

__construct()  : mixed
disableIntlSupport()  : mixed
Arbitrarily turnoff internationalization support for testing
getLine()  : array<int, string>|string
Parses the language string for a file, loads the file, if necessary, getting the line.
getLocale()  : string
setData()  : $this
Sets the data that should be returned by the 'requireFile()' method to allow easy overrides during testing.
setLocale()  : $this
Sets the current locale to use when performing string lookups.
formatMessage()  : array<string|int, mixed>|string
Advanced message formatting.
getTranslationOutput()  : array<string|int, mixed>|string|null
load()  : array<string|int, mixed>|void
Loads a language file in the current locale. If $return is true, will return the file's contents, otherwise will merge with the existing language lines.
parseLine()  : array<string|int, mixed>
Parses the language string which should include the filename as the first segment (separated by period).
requireFile()  : array<string|int, mixed>
Provides an override that allows us to set custom data to be returned easily during testing.

Properties

$data

Stores the data that should be returned by the 'requireFile()' method.

protected mixed $data

$intlSupport

Boolean value whether the intl libraries exist on the system.

protected bool $intlSupport = false

$language

Stores the retrieved language lines from files for faster retrieval on second use.

protected array<string|int, mixed> $language = []

$loadedFiles

Stores filenames that have been loaded so that we don't load them again.

protected array<string|int, mixed> $loadedFiles = []

$locale

The current language/locale to work with.

protected string $locale

Methods

__construct()

public __construct(string $locale) : mixed
Parameters
$locale : string

disableIntlSupport()

Arbitrarily turnoff internationalization support for testing

public disableIntlSupport() : mixed

getLine()

Parses the language string for a file, loads the file, if necessary, getting the line.

public getLine(string $line[, array<string|int, mixed> $args = [] ]) : array<int, string>|string
Parameters
$line : string
$args : array<string|int, mixed> = []
Return values
array<int, string>|string

getLocale()

public getLocale() : string
Return values
string

setData()

Sets the data that should be returned by the 'requireFile()' method to allow easy overrides during testing.

public setData(string $file, array<string|int, mixed> $data[, string|null $locale = null ]) : $this
Parameters
$file : string
$data : array<string|int, mixed>
$locale : string|null = null
Return values
$this

setLocale()

Sets the current locale to use when performing string lookups.

public setLocale([string|null $locale = null ]) : $this
Parameters
$locale : string|null = null
Return values
$this

formatMessage()

Advanced message formatting.

protected formatMessage(array<string|int, mixed>|string $message[, array<int, string> $args = [] ]) : array<string|int, mixed>|string
Parameters
$message : array<string|int, mixed>|string
$args : array<int, string> = []
Return values
array<string|int, mixed>|string

getTranslationOutput()

protected getTranslationOutput(string $locale, string $file, string $parsedLine) : array<string|int, mixed>|string|null
Parameters
$locale : string
$file : string
$parsedLine : string
Return values
array<string|int, mixed>|string|null

load()

Loads a language file in the current locale. If $return is true, will return the file's contents, otherwise will merge with the existing language lines.

protected load(string $file, string $locale[, bool $return = false ]) : array<string|int, mixed>|void
Parameters
$file : string
$locale : string
$return : bool = false
Return values
array<string|int, mixed>|void

parseLine()

Parses the language string which should include the filename as the first segment (separated by period).

protected parseLine(string $line, string $locale) : array<string|int, mixed>
Parameters
$line : string
$locale : string
Return values
array<string|int, mixed>

requireFile()

Provides an override that allows us to set custom data to be returned easily during testing.

protected requireFile(string $path) : array<string|int, mixed>
Parameters
$path : string
Return values
array<string|int, mixed>

        
On this page

Search results