RdbAdmin Module

I18n
in package

I18n or internationalisation for the framework.

This class detect language base on configuration that it is on the URL or cookie.
After run this class you can get current language by accessing $_SERVER['RUNDIZBONES_LANGUAGE'].

Tags
since
0.1

Table of Contents

Properties

$Config  : Config
$Container  : Container

Methods

__construct()  : mixed
The class constructor.
init()  : string|null
Initialize the language/locale.
getLocale()  : mixed
Get locale to set in PHP.
redirect()  : mixed
Redirect and then exit.

Properties

Methods

__construct()

The class constructor.

public __construct(Container $Container) : mixed
Parameters
$Container : Container

The DI container class.

init()

Initialize the language/locale.

public init([string|null $response = '' ]) : string|null

After this middleware worked, you can access current language by different ways.
If config is using cookie, you can access it via $_COOKIES['rundizbones_language' . $this->Container['Config']->get('suffix', 'cookie')] If config is using anything, you can access it via $_SERVER['RUNDIZBONES_LANGUAGE']

Parameters
$response : string|null = ''
Return values
string|null

getLocale()

Get locale to set in PHP.

protected getLocale(string $languageId[, array<string|int, mixed> $allLanguages = [] ]) : mixed
Parameters
$languageId : string

The language ID to match in config.

$allLanguages : array<string|int, mixed> = []

The all languages in config file.

Return values
mixed

Return locale in string or array.

redirect()

Redirect and then exit.

protected redirect([string $url = '' ][, int $status = 307 ]) : mixed

It must use exit() because if it returns then other middlewares will still working which is waste of resource.

Parameters
$url : string = ''

The URL to be redirect to.

$status : int = 307

HTTP header status.

Tags
link

Redirect 302, 303, 307 difference.


        
On this page

Search results