CodeIgniter v4.6 API

Language
in package

Handle system messages and localization.

Locale-based, built on top of PHP internationalization.

Tags
phpstan-type

LoadedStrings array<string, array<string, array<string, string>|string>|string|list>

see
LanguageTest

Table of Contents

Properties

$intlSupport  : bool
Boolean value whether the `intl` extension exists on the system.
$language  : array<non-empty-string, array<non-empty-string, LoadedStrings>>
Stores the retrieved language lines from files for faster retrieval on second use.
$loadedFiles  : array<non-empty-string, array<int, non-empty-string>>
Stores filenames that have been loaded so that we don't load them again.
$locale  : non-empty-string
The current locale to work with.

Methods

__construct()  : mixed
getLine()  : array<int, string>|string
Parses the language string for a file, loads the file, if necessary, getting the line.
getLocale()  : string
setLocale()  : $this
Sets the current locale to use when performing string lookups.
formatMessage()  : mixed
Advanced message formatting.
getTranslationOutput()  : array<int, string>|string|null
load()  : mixed
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{: non-empty-string, : non-empty-string}
Parses the language string which should include the filename as the first segment (separated by period).
requireFile()  : LoadedStrings
A simple method for including files that can be overridden during testing.

Properties

$intlSupport

Boolean value whether the `intl` extension exists on the system.

protected bool $intlSupport = false

$language

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

protected array<non-empty-string, array<non-empty-string, LoadedStrings>> $language = []

$loadedFiles

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

protected array<non-empty-string, array<int, non-empty-string>> $loadedFiles = []

$locale

The current locale to work with.

protected non-empty-string $locale

Methods

__construct()

public __construct(non-empty-string $locale) : mixed
Parameters
$locale : non-empty-string

getLine()

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

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

getLocale()

public getLocale() : string
Return values
string

setLocale()

Sets the current locale to use when performing string lookups.

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

formatMessage()

Advanced message formatting.

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

getTranslationOutput()

protected getTranslationOutput(string $locale, string $file, string $parsedLine) : array<int, string>|string|null
Parameters
$locale : string
$file : string
$parsedLine : string
Return values
array<int, string>|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 ]) : mixed
Parameters
$file : string
$locale : string
$return : bool = false

parseLine()

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

protected parseLine(string $line, string $locale) : array{: non-empty-string, : non-empty-string}
Parameters
$line : string
$locale : string
Return values
array{: non-empty-string, : non-empty-string}

requireFile()

A simple method for including files that can be overridden during testing.

protected requireFile(string $path) : LoadedStrings
Parameters
$path : string
Return values
LoadedStrings

        
On this page

Search results