newInstance($cookies); $this->sessionSegment = $session->getSegment('Alltube\LocaleManager'); $cookieLocale = $this->sessionSegment->get('locale'); if (isset($cookieLocale)) { $this->setLocale(new Locale($cookieLocale)); } } /** * Get a list of supported locales. * * @return Locale[] */ public function getSupportedLocales() { $return = []; foreach ($this->supportedLocales as $supportedLocale) { $return[] = new Locale($supportedLocale); } return $return; } /** * Get the current locale. * * @return Locale */ public function getLocale() { return $this->curLocale; } /** * Set the current locale. * * @param Locale $locale Locale */ public function setLocale(Locale $locale) { putenv('LANG='.$locale); setlocale(LC_ALL, [$locale, $locale.'.utf8']); $this->curLocale = $locale; $this->sessionSegment->set('locale', $locale); } }