Documentation

Lang
in package

Table of Contents

Properties

$currentLang  : string
$defaultLang  : string
$langDir  : string
$supported  : array<string|int, mixed>
$translations  : array<string|int, mixed>

Methods

getCurrentLang()  : string
getPersistedCookie()  : mixed
getSupportedLangs()  : array<string|int, mixed>
Returns an array with supported languages
getTranslations()  : array<string|int, mixed>
Returns the translation array
isSupportedLang()  : bool
persistCookie()  : void
resolve()  : void
Resolve and load the language from cookie, then fallback to default.
set()  : void
Explicitly set a language and persist it in a cookie.
t()  : string
Translate a key. Falls back to the key itself if not found.
load()  : void
Loads the translations

Properties

$currentLang

private string $currentLang

$defaultLang

private string $defaultLang = 'en'

$langDir

private string $langDir = '/src/lang'

$supported

private array<string|int, mixed> $supported = ['en', 'de', 'bg', 'fr']

$translations

private array<string|int, mixed> $translations = []

Methods

getCurrentLang()

public getCurrentLang() : string
Return values
string

getPersistedCookie()

public getPersistedCookie() : mixed

getSupportedLangs()

Returns an array with supported languages

public getSupportedLangs() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTranslations()

Returns the translation array

public getTranslations() : array<string|int, mixed>
Return values
array<string|int, mixed>

isSupportedLang()

public isSupportedLang(string|null $lang) : bool
Parameters
$lang : string|null
Return values
bool

persistCookie()

public persistCookie(string $lang) : void
Parameters
$lang : string

resolve()

Resolve and load the language from cookie, then fallback to default.

public resolve() : void

set()

Explicitly set a language and persist it in a cookie.

public set(string $lang) : void
Parameters
$lang : string

t()

Translate a key. Falls back to the key itself if not found.

public t(string $key) : string
Parameters
$key : string
Return values
string

load()

Loads the translations

private load(string $lang) : void
Parameters
$lang : string
Tags
throws
RuntimeException

        
On this page

Search results