/**
  *
  * @param string $user_ID
  */
 public function getRenderLanguage($user_ID = false)
 {
     if (!$user_ID) {
         global $user_ID;
     }
     $user = User::find($user_ID);
     // Format the list
     $userLang = $user->getLang();
     foreach (I18n::getAllLangAvailable() as $t) {
         $languages[] = ['value' => $t, 'text' => I18n::transu('lang_' . $t), 'selected' => $userLang == $t];
     }
     $args = ['user' => $user, 'KEY_LANGUAGE' => User::KEY_LANGUAGE, 'languages' => $languages];
     return $this->render('backend/user/_lang', $args);
 }
Ejemplo n.º 2
0
 /**
  *
  * @return array
  */
 public static function getAllLangAvailableKeyValue()
 {
     $languages = [];
     foreach (I18n::getAllLangAvailable() as $l) {
         $languages[] = ['key' => $l, 'value' => I18n::getLangFullnameBrowser($l)];
     }
     /*
      * Sort by key
      */
     usort($languages, function ($a, $b) {
         return strcasecmp($a['key'], $b['key']);
     });
     return $languages;
 }
Ejemplo n.º 3
0
 *
 * (c) José María Valera Reales <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Knob\I18n\I18n;
/**
 * NOTE:
 * For to use this page remember that you have to create your own
 * page through the backend from Wordpress.
 *
 * @example yoursite.com/lang?lang=en
 */
$lang = $_GET['lang'];
$redirect = $_GET['redirect'];
/*
 * Check if the lang is available
 */
if (in_array($lang, I18n::getAllLangAvailable())) {
    session_start();
    $_SESSION[I18n::CURRENT_LANG] = $lang;
}
/*
 * We only redirect the url if not is absolute
 */
if (!$redirect || strpos($redirect, 'http') !== false || strpos($redirect, 'https') !== false) {
    header("Location: /");
} else {
    header("Location: {$redirect}");
}