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