mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
Parsing request language header
This commit is contained in:
parent
73d89b7d05
commit
c15928bcc9
|
|
@ -139,6 +139,7 @@ class Request extends RequestAbstract
|
||||||
{
|
{
|
||||||
$this->data = $_GET ?? [];
|
$this->data = $_GET ?? [];
|
||||||
$this->files = $_FILES ?? [];
|
$this->files = $_FILES ?? [];
|
||||||
|
$this->language = $this->loadRequestLanguage();
|
||||||
|
|
||||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||||
if (strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
|
if (strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
|
||||||
|
|
@ -156,6 +157,15 @@ class Request extends RequestAbstract
|
||||||
$this->uri = $this->uri ?? new Http(Http::getCurrent());
|
$this->uri = $this->uri ?? new Http(Http::getCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function loadRequestLanguage() : string
|
||||||
|
{
|
||||||
|
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||||
|
$lang = explode(';', $lang);
|
||||||
|
$lang = explode('-', $lang[0]);
|
||||||
|
|
||||||
|
return $lang[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init pseudo request
|
* Init pseudo request
|
||||||
*
|
*
|
||||||
|
|
@ -216,6 +226,14 @@ class Request extends RequestAbstract
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getLanguage() : string
|
||||||
|
{
|
||||||
|
return $this->language;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create request hashs of current request
|
* Create request hashs of current request
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,21 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
protected $path = [];
|
protected $path = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language.
|
* Localization.
|
||||||
*
|
*
|
||||||
* @var Localization
|
* @var Localization
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $l11n = null;
|
protected $l11n = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $language = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account.
|
* Account.
|
||||||
*
|
*
|
||||||
|
|
@ -168,6 +176,16 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
$this->uri = $uri;
|
$this->uri = $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get request language.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
abstract public function getLanguage() : string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get request hash.
|
* Get request hash.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user