CodeIgniter v4.5 API

Language
in package

Handle system messages and localization.

Locale-based, built on top of PHP internationalization.

Tags
see
LanguageTest

Table of Contents

Properties

$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
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()  : 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>
A simple method for including files that can be overridden during testing.

Properties

$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

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

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()

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

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

        
On this page

Search results