From 6ad93dff69d7c2beb2196e73f641e6484fccbeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 20 Jan 2015 07:40:39 +0100 Subject: new folders --- inc/poche/Language.class.php | 114 ------------------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 inc/poche/Language.class.php (limited to 'inc/poche/Language.class.php') diff --git a/inc/poche/Language.class.php b/inc/poche/Language.class.php deleted file mode 100644 index 420f2fb9..00000000 --- a/inc/poche/Language.class.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright 2013 - * @license http://opensource.org/licenses/MIT see COPYING file - */ - -class Language -{ - protected $wallabag; - - private $currentLanguage; - - private $languageNames = array( - 'cs_CZ.utf8' => 'čeština', - 'de_DE.utf8' => 'German', - 'en_EN.utf8' => 'English', - 'en_US.utf8' => 'English (US)', - 'es_ES.utf8' => 'Español', - 'fa_IR.utf8' => 'فارسی', - 'fr_FR.utf8' => 'Français', - 'it_IT.utf8' => 'Italiano', - 'pl_PL.utf8' => 'Polski', - 'pt_BR.utf8' => 'Português (Brasil)', - 'ru_RU.utf8' => 'Pусский', - 'sl_SI.utf8' => 'Slovenščina', - 'uk_UA.utf8' => 'Українська', - ); - - public function __construct(Poche $wallabag) - { - $this->wallabag = $wallabag; - $pocheUser = Session::getParam('poche_user'); - $language = (is_null($pocheUser) ? LANG : $pocheUser->getConfigValue('language')); - - @putenv('LC_ALL=' . $language); - setlocale(LC_ALL, $language); - bindtextdomain($language, LOCALE); - textdomain($language); - - $this->currentLanguage = $language; - } - - public function getLanguage() { - return $this->currentLanguage; - } - - public function getInstalledLanguages() { - $handle = opendir(LOCALE); - $languages = array(); - - while (($language = readdir($handle)) !== false) { - # Languages are stored in a directory, so all directory names are languages - # @todo move language installation data to database - if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.', 'tools'))) { - continue; - } - - $current = false; - - if ($language === $this->getLanguage()) { - $current = true; - } - - $languages[] = array('name' => (isset($this->languageNames[$language]) ? $this->languageNames[$language] : $language), 'value' => $language, 'current' => $current); - } - - return $languages; - } - - - /** - * Update language for current user - * - * @param $newLanguage - */ - public function updateLanguage($newLanguage) - { - # we are not going to change it to the current language - if ($newLanguage == $this->getLanguage()) { - $this->wallabag->messages->add('w', _('still using the "' . $this->getLanguage() . '" language!')); - Tools::redirect('?view=config'); - } - - $languages = $this->getInstalledLanguages(); - $actualLanguage = false; - - foreach ($languages as $language) { - if ($language['value'] == $newLanguage) { - $actualLanguage = true; - break; - } - } - - if (!$actualLanguage) { - $this->wallabag->messages->add('e', _('that language does not seem to be installed')); - Tools::redirect('?view=config'); - } - - $this->wallabag->store->updateUserConfig($this->wallabag->user->getId(), 'language', $newLanguage); - $this->wallabag->messages->add('s', _('you have changed your language preferences')); - - $currentConfig = $_SESSION['poche_user']->config; - $currentConfig['language'] = $newLanguage; - - $_SESSION['poche_user']->setConfig($currentConfig); - - Tools::emptyCache(); - Tools::redirect('?view=config'); - } -} -- cgit v1.2.3