<?php /** * radium: the most RAD PHP Framework * * @copyright Copyright 2012, Playwell Inc. * @license http://opensource.org/licenses/bsd-license.php The BSD License */ use radium\storage\Session; $uri = $this->request->uri; list($lang, $country) = explode('_', Session::read('lang')); $title = $this->title(); if (!$title) { $title = $this->title('radium PHP Framework'); } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml"> <head> <?php echo $this->html->charset(); ?> <title><?php echo $this->title(); ?> </title> <meta name="viewport" content="user-scalable=no; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.0" /> <?php
public static final function getLocalizedString($key, array $params = array(), $escape = false) { $lang = null; if (!static::$radiumLocaleResources || !defined('DEFAULT_LANG')) { $radiumLocaleResources = array(); $i18nDir = RADIUM_APP_PATH . '/i18n'; if (is_dir($i18nDir)) { if ($dh = opendir($i18nDir)) { while (($file = readdir($dh)) !== false) { if (preg_match('/\\.php$/', $file)) { include $i18nDir . '/' . $file; } } closedir($dh); } } static::$radiumLocaleResources = $radiumLocaleResources; if (!defined('DEFAULT_LANG')) { $langs = array(); $headers = getallheaders(); if (isset($headers['Accept-Language'])) { $langs = explode(',', $headers['Accept-Language']); } if (isset($_GET['lang'])) { $langParam = $_GET['lang']; if ($langParam == '' || $langParam == 'default') { Session::delete('lang'); } else { Session::write('lang', $langParam); } } $sessionLang = Session::read('lang'); if ($sessionLang) { $langs = explode(',', $sessionLang); } $langResources = array_keys($radiumLocaleResources); foreach ($langs as $l) { if (preg_match('/^([a-z]+)[-_]([a-zA-Z0-9]+)$/', $l, $matches)) { $l = $matches[1] . '_' . strtoupper($matches[2]); foreach ($langResources as $langResource) { if ($langResource == $l) { define('DEFAULT_LANG', $langResource); break; } } } else { if (preg_match('/^[a-z]+$/', $l)) { foreach ($langResources as $langResource) { list($locale, $country) = explode('_', $langResource); if ($locale == $l) { define('DEFAULT_LANG', $langResource); break; } } } } if (defined('DEFAULT_LANG')) { break; } } } if (!defined('DEFAULT_LANG')) { define('DEFAULT_LANG', 'en_US'); } Session::write('lang', DEFAULT_LANG); } $result = $key; $radiumLocaleResources = static::$radiumLocaleResources; if (isset($radiumLocaleResources[DEFAULT_LANG][$key])) { $result = $radiumLocaleResources[DEFAULT_LANG][$key]; } else { if (isset($radiumLocaleResources['en_US'][$key])) { $result = $radiumLocaleResources['en_US'][$key]; } } if (is_array($params)) { $n = count($params); for ($i = 0; $i < $n; $i++) { $result = str_replace('{' . ($i + 1) . '}', $escape ? static::escape($params[$i]) : $params[$i], $result); } } return $result; }