mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
RETROTEC-AG/OpenXE#17 Locale des GUI-Users ermitteln
Systemeinstellungen als default vorgeben
This commit is contained in:
parent
6695369af7
commit
7c4c9e64d6
@ -111,6 +111,19 @@ final class Bootstrap
|
||||
/** @var Database $db */
|
||||
$db = $container->get('Database');
|
||||
|
||||
$config=[];
|
||||
$firmaLang=null;
|
||||
$firmaRegion=null;
|
||||
// Get language from system settings and normalize to 3-letter-code and 2-letter-code
|
||||
if ($firmaLang = self::findLanguage($app->erp->Firmendaten('preferredLanguage'))) {
|
||||
$config[Localization::LANGUAGE_DEFAULT] = $firmaLang[Iso639\Key::ALPHA_3];
|
||||
}
|
||||
|
||||
// Get region from system settings and normalize to 2-letter-code
|
||||
if ($firmaLang && ($firmaRegion = self::findRegion($app->erp->Firmendaten('land')))) {
|
||||
$config[Localization::LOCALE_DEFAULT] = "{$firmaLang[Iso639\Key::ALPHA_2]}_{$firmaRegion[Iso3166\Key::ALPHA_2]}";
|
||||
}
|
||||
|
||||
|
||||
// Get User
|
||||
$usersettings = [];
|
||||
@ -122,17 +135,17 @@ final class Bootstrap
|
||||
);
|
||||
|
||||
// Get language from user account and normalize to 3-letter-code and 2-letter-code
|
||||
if ($lang = self::findLanguage($user->GetSprache())) {
|
||||
$usersettings['language'] = $lang[Iso639\Key::ALPHA_3];
|
||||
if ($userLang = self::findLanguage($user->GetSprache())) {
|
||||
$usersettings['language'] = $userLang[Iso639\Key::ALPHA_3];
|
||||
}
|
||||
|
||||
// Get region from user account and normalize to 2-letter-code
|
||||
if ($lang && ($region = self::findRegion($userAddress['land']))) {
|
||||
$usersettings['locale'] = "{$lang[Iso639\Key::ALPHA_2]}_{$region[Iso3166\Key::ALPHA_2]}";
|
||||
if ($userLang && ($userRegion = self::findRegion($userAddress['land']))) {
|
||||
$usersettings['locale'] = "{$userLang[Iso639\Key::ALPHA_2]}_{$userRegion[Iso3166\Key::ALPHA_2]}";
|
||||
}
|
||||
}
|
||||
|
||||
// Create Localization object
|
||||
return new Localization($request, $session, $usersettings);
|
||||
return new Localization($request, $session, $usersettings, $config);
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ final class Localization implements LocalizationInterface
|
||||
|
||||
|
||||
|
||||
public function __construct(?Request $request, ?Session $session, array $usersettings = [])
|
||||
public function __construct(?Request $request, ?Session $session, array $usersettings = [], array $config = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->session = $session;
|
||||
$this->usersettings = $usersettings;
|
||||
$this->config = [];
|
||||
$this->config = $config;
|
||||
$this->process();
|
||||
}
|
||||
|
||||
@ -55,8 +55,6 @@ final class Localization implements LocalizationInterface
|
||||
$langAttrName = $this->config[Localization::LANGUAGE_ATTRIBUTE_NAME] ?? 'language';
|
||||
|
||||
$segmentName = 'i18n';
|
||||
// $session = $this->session;
|
||||
// $request = $this->request;
|
||||
|
||||
// Get the locale from the session, if available
|
||||
if ($this->session && ($locale = $this->session->getValue($segmentName, $localeAttrName))) {
|
||||
|
Loading…
Reference in New Issue
Block a user