diff options
author | msquare <msquare@notrademark.de> | 2019-07-21 13:32:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-21 13:32:45 +0200 |
commit | d4d4b409b6fd96ca297af323936b8922d45b6eda (patch) | |
tree | 6c8efa1a1e429f3965820838796cb4b97cd2df11 /src/Helpers/TranslationServiceProvider.php | |
parent | d5bf7fd065a5ea93dea9fd55e6ac225ee062a3db (diff) | |
parent | 51a3c6eb44a5dbdf9d7a3cfac678f0d29b0d3eef (diff) |
Merge pull request #622 from MyIgel/controllers
AuthController (login, logout), use templating, replaced gettext, input validation
Diffstat (limited to 'src/Helpers/TranslationServiceProvider.php')
-rw-r--r-- | src/Helpers/TranslationServiceProvider.php | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/src/Helpers/TranslationServiceProvider.php b/src/Helpers/TranslationServiceProvider.php deleted file mode 100644 index 4565dfcd..00000000 --- a/src/Helpers/TranslationServiceProvider.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php - -namespace Engelsystem\Helpers; - -use Engelsystem\Config\Config; -use Engelsystem\Container\ServiceProvider; -use Symfony\Component\HttpFoundation\Session\Session; - -class TranslationServiceProvider extends ServiceProvider -{ - public function register() - { - /** @var Config $config */ - $config = $this->app->get('config'); - /** @var Session $session */ - $session = $this->app->get('session'); - - $locales = $config->get('locales'); - $locale = $config->get('default_locale'); - - $sessionLocale = $session->get('locale', $locale); - if (isset($locales[$sessionLocale])) { - $locale = $sessionLocale; - } - - $this->initGettext(); - $session->set('locale', $locale); - - $translator = $this->app->make( - Translator::class, - ['locale' => $locale, 'locales' => $locales, 'localeChangeCallback' => [$this, 'setLocale']] - ); - $this->app->instance(Translator::class, $translator); - $this->app->instance('translator', $translator); - } - - /** - * @param string $textDomain - * @param string $encoding - * @codeCoverageIgnore - */ - protected function initGettext($textDomain = 'default', $encoding = 'UTF-8') - { - bindtextdomain($textDomain, $this->app->get('path.lang')); - bind_textdomain_codeset($textDomain, $encoding); - textdomain($textDomain); - } - - /** - * @param string $locale - * @codeCoverageIgnore - */ - public function setLocale($locale) - { - // Set the users locale - putenv('LC_ALL=' . $locale); - setlocale(LC_ALL, $locale); - - // Reset numeric formatting to allow output of floats - putenv('LC_NUMERIC=C'); - setlocale(LC_NUMERIC, 'C'); - } -} |