function startup_gettext() { # Get locale from Accept-Language header $lang = al2gt(array_keys(get_translations()), "text/html"); if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) { $lang = _TRANSLATION_OVERRIDE_DEFAULT; } if ($_SESSION["uid"] && get_schema_version() >= 120) { $pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"]); if ($pref_lang && $pref_lang != 'auto') { $lang = $pref_lang; } } if ($lang) { if (defined('LC_MESSAGES')) { _setlocale(LC_MESSAGES, $lang); } else { if (defined('LC_ALL')) { _setlocale(LC_ALL, $lang); } } _bindtextdomain("messages", "locale"); _textdomain("messages"); _bind_textdomain_codeset("messages", "UTF-8"); } }
function startup_gettext() { # Get locale from Accept-Language header $lang = al2gt(array_keys(get_translations()), "text/html"); if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) { $lang = _TRANSLATION_OVERRIDE_DEFAULT; } /* In login action of mobile version */ if ($_POST["language"] && defined('MOBILE_VERSION')) { $lang = $_POST["language"]; } else { if ($_SESSION["language"] && $_SESSION["language"] != "auto") { $lang = $_SESSION["language"]; } } if ($lang) { if (defined('LC_MESSAGES')) { _setlocale(LC_MESSAGES, $lang); } else { if (defined('LC_ALL')) { _setlocale(LC_ALL, $lang); } } if (defined('MOBILE_VERSION')) { _bindtextdomain("messages", "../locale"); } else { _bindtextdomain("messages", "locale"); } _textdomain("messages"); _bind_textdomain_codeset("messages", "UTF-8"); } }
/** * bind text domain. * * @param string $domain text domain * @param string $directory directory where the translation file is. the directory must have trailing slash. * @param string $language_locale_uri language to check translation file exists. */ public function bindTextDomain($domain, $directory, $language_locale_uri) { if (is_file($directory . $language_locale_uri . DS . 'LC_MESSAGES' . DS . $domain . '.mo') && function_exists('_bindtextdomain') && function_exists('_bind_textdomain_codeset')) { _bindtextdomain($domain, $directory); _bind_textdomain_codeset($domain, $this->encoding); } }
public function setUp() { MoTranslator\Loader::loadFunctions(); _setlocale(0, 'cs'); _textdomain('phpmyadmin'); _bindtextdomain('phpmyadmin', __DIR__ . '/data/locale/'); _bind_textdomain_codeset('phpmyadmin', 'UTF-8'); }
function changeLocale($newlocale) { global $CURRENTLOCALE, $EMULATEGETTEXT, $text_domains; $CURRENTLOCALE = $newlocale; $EMULATEGETTEXT = 1; _textdomain('kusaba'); _setlocale(LC_ALL, $newlocale); _bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang', $newlocale); _bind_textdomain_codeset('kusaba', KU_CHARSET); }
function init_locale($locale, $error = 'error') { if (_setlocale(LC_ALL, $locale) === false) { $error('The specified locale (' . $locale . ') does not exist on your platform!'); } if (extension_loaded('gettext')) { bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard'); } }
function init_locale($locale, $error = 'error') { if ($locale === 'en') { $locale = 'en_US.utf8'; } if (extension_loaded('gettext')) { setlocale(LC_ALL, $locale); bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { _setlocale(LC_ALL, $locale); _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard'); } }
/** * Smarty block function, provides gettext support for smarty. * * The block content is the text that should be translated. * * Any parameter that is sent to the function will be represented as %n in the translation text, * where n is 1 for the first parameter. The following parameters are reserved: * - escape - sets escape mode: * - 'html' for HTML escaping, this is the default. * - 'js' for javascript escaping. * - 'url' for url escaping. * - 'no'/'off'/0 - turns off escaping * - plural - The plural version of the text (2nd parameter of ngettext()) * - count - The item count for plural mode (3rd parameter of ngettext()) */ function smarty_block_t($params, $text, &$smarty) { //ADDING PHP-GETTEXT SUPPORT //error_reporting(E_ALL | E_STRICT); //for debugging $settings = setupPhpGettext(); extract($settings); /* if(!defined('PROJECT_DIR')) define('PROJECT_DIR', $project_dir); if(!defined('LOCALE_DIR')) define('LOCALE_DIR', $locale_dir); if(!defined('DEFAULT_LOCALE')) define('DEFAULT_LOCALE', $default_locale); */ // gettext setup T_setlocale(LC_MESSAGES, $locale); // Set the text domain as 'messages' $domain = 'messages'; _bindtextdomain($domain, LOCALE_DIR); // bind_textdomain_codeset is supported only in PHP 4.2.0+ if (function_exists('bind_textdomain_codeset')) { _bind_textdomain_codeset($domain, $encoding); } _textdomain($domain); // end PHP-GETTEXT SUPPORT $text = stripslashes($text); // set escape mode if (isset($params['escape'])) { $escape = $params['escape']; unset($params['escape']); } // set plural version if (isset($params['plural'])) { $plural = $params['plural']; unset($params['plural']); // set count if (isset($params['count'])) { $count = $params['count']; unset($params['count']); } } // use plural if required parameters are set if (isset($count) && isset($plural)) { $text = _ngettext($text, $plural, $count); } else { // use normal $text = _gettext($text); } // run strarg if there are parameters if (count($params)) { $text = smarty_gettext_strarg($text, $params); } if (!isset($escape) || $escape == 'html') { // html escape, default $text = nl2br(htmlspecialchars($text)); } elseif (isset($escape)) { switch ($escape) { case 'javascript': case 'js': // javascript escape $text = str_replace('\'', '\\\'', stripslashes($text)); break; case 'url': // url escape $text = urlencode($text); break; } } return $text; }
function bindtextdomain($domain, $path) { return _bindtextdomain($domain, $path); }
* 2. Supply an array that lists all available translations (main * purpose is to use it for creating html selects to change language) * * TODO: Maybe change $available_languages to just list the native * language name (well, useres should be able to find their own * language, shouldn't they?) :) * NOTE: The gettext library might be used, if it is available. * The problem is that mo files are cached by the extension, so a * server restart is necessary if these files are updated (e.g. by * a senayan update). I replaced all _('') with __(''), so * php-gettext is always used, thus circumventing this problem. * Obviously there is no real speed disadvantage, since this is the * way wordpress does it. * Developers should use __('') and _ngettext in code! */ // gettext setup $locale = $sysconf['default_lang']; $domain = 'messages'; $encoding = 'UTF-8'; // set language to use T_setlocale(LC_ALL, $locale); // set locales dictionary location _bindtextdomain($domain, INC_DIR . 'locale'); // codeset _bind_textdomain_codeset($domain, $encoding); // set .mo filename to use _textdomain($domain); // Array with available translations // $available_languages[] = array('CODE', __('ENGLISH NAME'), 'NATIVE NAME'); $available_languages[] = array('en_US', __('English'), 'English'); $available_languages[] = array('id_ID', __('Indonesian'), 'Indonesia');
<?php include_once 'application/lib/gettext/gettext.inc.php'; _bindtextdomain(); class kxTemplate { private static $template_dir; private static $debug_flag = false; private static $data = array(); private static $instance = null; // Manage wrapper private static $manage; // Manage sidebar menu extras public static $menu_extra = ''; private function __construct() { } public static function init($template_dir = null, $compiled_dir = null, $cache_dir = null) { if (self::$instance == null) { //echo "<p>init() called!</p>"; if ($template_dir != null) { self::$template_dir = $template_dir; } else { self::$template_dir = KX_ROOT . kxEnv::get("kx:templates:dir"); } $loader = new Twig_Loader_Filesystem(self::$template_dir); if ($cache_dir == null) { $cache_dir = KX_ROOT . kxEnv::get("kx:templates:cachedir"); } self::$instance = new Twig_Environment($loader, array('cache' => $cache_dir, 'auto_reload' => true, 'debug' => true));
* Developers should use __('') and _ngettext in code! */ // key to authenticate if (!defined('INDEX_AUTH')) { define('INDEX_AUTH', '1'); } // set php-gettext library require LANG . 'php-gettext' . DS . 'gettext.inc'; // gettext setup $locale = $sysconf['default_lang']; $domain = 'messages'; $encoding = 'UTF-8'; // set language to use T_setlocale(LC_ALL, $locale); // set locales dictionary location _bindtextdomain($domain, LANG . 'locale'); // codeset _bind_textdomain_codeset($domain, $encoding); // set .mo filename to use _textdomain($domain); // Array with available translations // $available_languages[] = array('CODE', __('ENGLISH NAME'), 'NATIVE NAME'); $available_languages[] = array('ar_AR', __('Arabic'), 'Arabic'); $available_languages[] = array('bn_BD', __('Bengali'), 'Bengali'); $available_languages[] = array('pt_BR', __('Brazilian Portuguese'), 'Brazilian Portuguese'); $available_languages[] = array('cn_PRC', __('Chinese'), 'Chinese'); $available_languages[] = array('kr_KR', __('Korean'), 'Korean'); $available_languages[] = array('en_US', __('English'), 'English'); $available_languages[] = array('es_ES', __('Espanol'), 'Espanol'); $available_languages[] = array('de_DE', __('German'), 'Deutsch'); $available_languages[] = array('id_ID', __('Indonesian'), 'Indonesia');
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. include_once dirname(__FILE__) . '/php-gettext/gettext.inc'; include_once dirname(__FILE__) . '/iso-set.php'; if (!defined('SESSION_DISABLE')) { LoadObjectDependency('net.php.pear.HTTP_Session2'); $lang = HTTP_Session2::get('language', DEFAULT_LANGUAGE); } else { $lang = DEFAULT_LANGUAGE; } $locale_dir = dirname(dirname(__FILE__)) . '/locale'; $__domains = array('freemed', UI); _setlocale(LC_MESSAGES, $lang); $GLOBALS['ISOSET'] = language2isoset($lang); foreach ($__domains as $_v) { _bindtextdomain($_v, $locale_dir); _bind_textdomain_codeset($_v, language2isoset($lang)); _textdomain($_v); } function get_translation_matrix($domain) { global $default_domain; $default_domain = $domain; $l10n = _get_reader(); return $l10n->cache_translations; } // end method get_translation_matrix
} } function ev_ngettext($string, $plural, $number) { return ngettext($string, $plural, $number); } function _bind_textdomain_codeset($domain, $codeset) { return bind_textdomain_codeset($domain, $codeset); } function _bindtextdomain($domain, $path) { return bindtextdomain($domain, $path); } function _textdomain($domain) { return textdomain($domain); } function _gettext($msgid) { return gettext($msgid); } function _setlocale($category, $locale) { return setlocale($category, $locale); } } // this won't change over the request. so set it once and permanently _bindtextdomain('eventum', APP_PATH . '/localization/'); _bind_textdomain_codeset('eventum', APP_CHARSET); _textdomain('eventum');
<?php require_once 'config.php'; $locale = LANG; $textdomain = "multi_lang"; $locales_dir = dirname(__FILE__) . '/lang'; if (isset($_GET['lang']) && !empty($_GET['lang'])) { $locale = $_GET['lang']; } putenv('LANGUAGE=' . $locale); putenv('LANG=' . $locale); putenv('LC_ALL=' . $locale); putenv('LC_MESSAGES=' . $locale); require_once 'lib/gettext.inc'; _setlocale(LC_ALL, $locale); _setlocale(LC_CTYPE, $locale); _bindtextdomain($textdomain, $locales_dir); _bind_textdomain_codeset($textdomain, 'UTF-8'); _textdomain($textdomain); /* * This function is an helper that should be * used to avoid some repetitions. Use "_e" * instead of "echo __". */ function _e($string) { echo __($string); }
/** Initilializes the chosen locales-module. */ function knjlocales_setmodule($domain, $dir, $module = "ext", $language = "auto"){ global $functions_knjlocales; $functions_knjlocales["dir"] = $dir; $functions_knjlocales["module"] = $module; if ($language == "auto"){ if (array_key_exists("HTTP_ACCEPT_LANGUAGE", $_SERVER) and $_SERVER["HTTP_ACCEPT_LANGUAGE"]){ $accept = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; foreach(explode(",", $accept) AS $value){ $value = explode(";", $value); $language = $value[0]; break; } }elseif($_SERVER["LANG"]){ if (preg_match("/^([a-z]{2}_[A-Z]{2})/", $_SERVER["LANG"], $match)){ $language = $match[1]; }else{ //Language could not be matched - default english. $language = "en_GB"; } } if ($language == "da"){ $language = "da_DK"; }elseif($language == "de"){ $language = "de_DE"; }elseif($language == "en"){ $language = "en_GB"; } } $language = strtr($language, array( "-" => "_" )); if (preg_match("/^([A-z]{2})_([A-z]{2})$/", $language, $match)){ $language = strtolower($match[1]) . "_" . strtoupper($match[2]); } $functions_knjlocales["language"] = $language; if (!file_exists($dir)){ throw new exception("Dir does not exist: " . $dir); } if ($module == "php-gettext"){ require_once "php-gettext/gettext.inc"; $functions_knjlocales["module"] = "php-gettext"; _setlocale(LC_ALL, $language);// or die("Locales error 5\n"); _setlocale(LC_MESSAGES, $language);// or die("Locales error 6\n"); _bindtextdomain($domain, $dir); _bind_textdomain_codeset($domain, "UTF-8"); _textdomain($domain); }elseif($module == "ext"){ require_once "knj/functions_knj_extensions.php"; if (!knj_dl("gettext")){ throw new exception("gettext-module could not be loaded."); } $functions_knjlocales["module"] = "ext"; putenv("LANGUAGE=" . $language); putenv("LC_ALL=" . $language); putenv("LC_MESSAGE=" . $language); putenv("LANG=" . $language); $locales_language_real = $language . ".utf8"; setlocale(LC_ALL, $locales_language_real); setlocale(LC_MESSAGES, $locales_language_real); bindtextdomain($domain, $dir); bind_textdomain_codeset($domain, "UTF-8"); textdomain($domain); }else{ throw new exception("knjlocales (" . __FILE__ . ":" . __LINE__ . "): No such module: " . $module . "\n"); } }
* TODO: Maybe change $available_languages to just list the native * language name (well, useres should be able to find their own * language, shouldn't they?) :) * NOTE: The gettext library might be used, if it is available. * The problem is that mo files are cached by the extension, so a * server restart is necessary if these files are updated (e.g. by * a senayan update). I replaced all _('') with __(''), so * php-gettext is always used, thus circumventing this problem. * Obviously there is no real speed disadvantage, since this is the * way wordpress does it. * Developers should use __('') and _ngettext in code! */ // set php-gettext library require LANGUAGES_BASE_DIR . 'php-gettext' . DIRECTORY_SEPARATOR . 'gettext.inc'; // gettext setup $locale = $sysconf['default_lang']; $domain = 'messages'; $encoding = 'UTF-8'; // set language to use T_setlocale(LC_ALL, $locale); // set locales dictionary location _bindtextdomain($domain, LANGUAGES_BASE_DIR . 'locale'); // codeset _bind_textdomain_codeset($domain, $encoding); // set .mo filename to use _textdomain($domain); // Array with available translations // $available_languages[] = array('CODE', __('ENGLISH NAME'), 'NATIVE NAME'); $available_languages[] = array('de_DE', __('German'), 'Deutsch'); $available_languages[] = array('en_US', __('English'), 'English'); $available_languages[] = array('id_ID', __('Indonesian'), 'Indonesia');
function loadConfig() { global $board, $config, $__ip, $debug, $__version, $microtime_start; $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; reset_events(); if (!isset($_SERVER['REMOTE_ADDR'])) { $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; } $arrays = array('db', 'api', 'cache', 'cookies', 'error', 'dir', 'mod', 'spam', 'filters', 'wordfilters', 'custom_capcode', 'custom_tripcode', 'dnsbl', 'dnsbl_exceptions', 'remote', 'allowed_ext', 'allowed_ext_files', 'file_icons', 'footer', 'stylesheets', 'additional_javascript', 'markup', 'custom_pages', 'dashboard_links'); $config = array(); foreach ($arrays as $key) { $config[$key] = array(); } require 'inc/config.php'; if (!file_exists('inc/instance-config.php')) { $error('Tinyboard is not configured! Create inc/instance-config.php.'); } require 'inc/instance-config.php'; if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { require $board['dir'] . '/config.php'; } if (!isset($__version)) { $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; } $config['version'] = $__version; date_default_timezone_set($config['timezone']); if (!isset($config['global_message'])) { $config['global_message'] = false; } if (!isset($config['post_url'])) { $config['post_url'] = $config['root'] . $config['file_post']; } if (!isset($config['referer_match'])) { if (isset($_SERVER['HTTP_HOST'])) { $config['referer_match'] = '/^' . (preg_match('@^https?://@', $config['root']) ? '' : 'https?:\\/\\/' . $_SERVER['HTTP_HOST']) . preg_quote($config['root'], '/') . '(' . str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . '(' . preg_quote($config['file_index'], '/') . '|' . str_replace('%d', '\\d+', preg_quote($config['file_page'])) . ')?' . '|' . str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . preg_quote($config['dir']['res'], '/') . str_replace('%d', '\\d+', preg_quote($config['file_page'], '/')) . '|' . preg_quote($config['file_mod'], '/') . '\\?\\/.+' . ')([#?](.+)?)?$/ui'; } else { // CLI mode $config['referer_match'] = '//'; } } if (!isset($config['cookies']['path'])) { $config['cookies']['path'] =& $config['root']; } if (!isset($config['dir']['static'])) { $config['dir']['static'] = $config['root'] . 'static/'; } if (!isset($config['image_sticky'])) { $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; } if (!isset($config['image_locked'])) { $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; } if (!isset($config['image_bumplocked'])) { $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; } if (!isset($config['image_deleted'])) { $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; } if (!isset($config['uri_thumb'])) { $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; } elseif (isset($board['dir'])) { $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); } if (!isset($config['uri_img'])) { $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; } elseif (isset($board['dir'])) { $config['uri_img'] = sprintf($config['uri_img'], $board['dir']); } if (!isset($config['uri_stylesheets'])) { $config['uri_stylesheets'] = $config['root'] . 'stylesheets/'; } if (!isset($config['url_stylesheet'])) { $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; } if (!isset($config['url_javascript'])) { $config['url_javascript'] = $config['root'] . $config['file_script']; } if (!isset($config['additional_javascript_url'])) { $config['additional_javascript_url'] = $config['root']; } if (!isset($config['uri_flags'])) { $config['uri_flags'] = $config['root'] . 'static/flags/%s.png'; } if ($config['root_file']) { chdir($config['root_file']); } if ($config['verbose_errors']) { set_error_handler('verbose_error_handler'); error_reporting(E_ALL); ini_set('display_errors', true); ini_set('html_errors', false); } // Keep the original address to properly comply with other board configurations if (!isset($__ip)) { $__ip = $_SERVER['REMOTE_ADDR']; } // ::ffff:0.0.0.0 if (preg_match('/^\\:\\:(ffff\\:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', $__ip, $m)) { $_SERVER['REMOTE_ADDR'] = $m[2]; } if ($config['locale'] != 'en') { if (_setlocale(LC_ALL, $config['locale']) === false) { $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); } if (extension_loaded('gettext')) { bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard'); } } if ($config['syslog']) { openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); } // open a connection to sysem logger if ($config['recaptcha']) { require_once 'inc/lib/recaptcha/recaptchalib.php'; } if ($config['cache']['enabled']) { require_once 'inc/cache.php'; } event('load-config'); if ($config['debug']) { if (!isset($debug)) { $debug = array('sql' => array(), 'exec' => array(), 'purge' => array(), 'cached' => array(), 'write' => array(), 'time' => array('db_queries' => 0, 'exec' => 0), 'start' => $microtime_start, 'start_debug' => microtime(true)); $debug['start'] = $microtime_start; } } }
for ($i = 0; $i < count($arr); $i++) { require PHPDISK_ROOT . 'includes/class/' . $arr[$i] . '.class.php'; } require PHPDISK_ROOT . 'includes/phpdisk_version.inc.php'; $C['gz']['open'] = $settings['gzipcompress']; phpdisk_core::gzcompress_open(); $db = phpdisk_core::init_db_connect(); $setting_file = PHPDISK_ROOT . 'system/settings.inc.php'; file_exists($setting_file) ? require_once $setting_file : settings_cache(); $arr = phpdisk_core::init_lang_tpl(); $user_tpl_dir = 'templates/default/'; $admin_tpl_dir = $arr['admin_tpl_dir']; $C['lang_type'] = $arr['lang_name']; require PHPDISK_ROOT . 'includes/lib/php-gettext/gettext.inc.php'; _setlocale(LC_MESSAGES, $C['lang_type']); _bindtextdomain('phpdisk', 'languages'); _bind_textdomain_codeset('phpdisk', $charset); _textdomain('phpdisk'); if (!@get_magic_quotes_gpc()) { $_GET = addslashes_array($_GET); $_POST = addslashes_array($_POST); $_COOKIE = addslashes_array($_COOKIE); } $group_settings_file = PHPDISK_ROOT . 'system/global/group_settings.inc.php'; file_exists($group_settings_file) ? require_once $group_settings_file : group_settings_cache(); list($pd_uid, $pd_gid, $pd_username, $pd_pwd, $pd_email) = gpc('phpdisk_zcore_info', 'C', '') ? explode("\t", pd_encode(gpc('phpdisk_zcore_info', 'C', ''), 'DECODE')) : array('', '', '', '', ''); $pd_uid = (int) $pd_uid; if (!$pd_uid || !$pd_pwd) { $pd_uid = 0; } else { $userinfo = $db->fetch_one_array("select userid,u.gid,username,password,email,group_name from {$tpf}users u,{$tpf}groups g where username='******' and password='******' and u.gid=g.gid limit 1");
exit; } define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); define('GNUSOCIAL', true); define('STATUSNET', true); // compatibility require_once INSTALLDIR . '/scripts/commandline.inc'; require_once INSTALLDIR . '/extlib/php-gettext/gettext.inc'; common_init_locale("en_US"); common_init_locale('fr'); putenv("LANG=fr"); putenv("LANGUAGE=fr"); setlocale('fr.utf8'); _setlocale('fr.utf8'); _bindtextdomain("statusnet", INSTALLDIR . '/locale'); _bindtextdomain("FeedSub", INSTALLDIR . '/plugins/FeedSub/locale'); $times = 10000; $delta = array(); $start = microtime(true); for ($i = 0; $i < $times; $i++) { $result = _("Send"); } $delta["_"] = array((microtime(true) - $start) / $times, $result); $start = microtime(true); for ($i = 0; $i < $times; $i++) { $result = __("Send"); } $delta["__"] = array((microtime(true) - $start) / $times, $result); $start = microtime(true); for ($i = 0; $i < $times; $i++) { $result = dgettext("FeedSub", "Feeds");
/** * Activates given translation * * @return bool */ public function activate() { $GLOBALS['lang'] = $this->code; // Set locale _setlocale(LC_MESSAGES, $this->code); _bindtextdomain('phpmyadmin', LOCALE_PATH); _bind_textdomain_codeset('phpmyadmin', 'UTF-8'); _textdomain('phpmyadmin'); /* Text direction for language */ if ($this->isRTL()) { $GLOBALS['text_dir'] = 'rtl'; } else { $GLOBALS['text_dir'] = 'ltr'; } /* TCPDF */ $GLOBALS['l'] = array(); /* TCPDF settings */ $GLOBALS['l']['a_meta_charset'] = 'UTF-8'; $GLOBALS['l']['a_meta_dir'] = $GLOBALS['text_dir']; $GLOBALS['l']['a_meta_language'] = $this->code; /* TCPDF translations */ $GLOBALS['l']['w_page'] = __('Page number:'); /* Show possible warnings from langauge selection */ LanguageManager::getInstance()->showWarnings(); }
} unset($cf); } // DO NOT MODIFY BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING OR ELSE BAD THINGS MAY HAPPEN $modules_loaded = array(); $required = array(KU_ROOTDIR, KU_WEBFOLDER, KU_WEBPATH); if (in_array('CHANGEME', $required) || in_array('', $required)) { echo 'You must set KU_ROOTDIR, KU_WEBFOLDER, and KU_WEBPATH before installation will finish!'; die; } require KU_ROOTDIR . 'lib/gettext/gettext.inc.php'; require KU_ROOTDIR . 'lib/adodb/adodb.inc.php'; // Gettext _textdomain('kusaba'); _setlocale(LC_ALL, KU_LOCALE); _bindtextdomain('kusaba', KU_ROOTDIR . 'inc/lang'); _bind_textdomain_codeset('kusaba', KU_CHARSET); // SQL database if (!isset($tc_db) && !isset($preconfig_db_unnecessary)) { $tc_db =& NewADOConnection(KU_DBTYPE); if (KU_DBUSEPERSISTENT) { $tc_db->PConnect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg()); mysql_query('SET NAMES utf8'); } else { $tc_db->Connect(KU_DBHOST, KU_DBUSERNAME, KU_DBPASSWORD, KU_DBDATABASE) or die('SQL database connection error: ' . $tc_db->ErrorMsg()); mysql_query('SET NAMES utf8'); } // SQL debug if (KU_DEBUG) { $tc_db->debug = true; }
* Do the work! */ if (!PMA_langCheck()) { // fallback language $fall_back_lang = 'en'; $line = __LINE__; if (!PMA_langSet($fall_back_lang)) { trigger_error('phpMyAdmin-ERROR: invalid lang code: ' . __FILE__ . '#' . $line . ', check hard coded fall back language.', E_USER_WARNING); // stop execution // and tell the user that his chosen language is invalid PMA_fatalError('Could not load any language, ' . 'please check your language settings and folder.'); } } // Set locale _setlocale(LC_MESSAGES, $GLOBALS['lang']); _bindtextdomain('phpmyadmin', $GLOBALS['lang_path']); _bind_textdomain_codeset('phpmyadmin', 'UTF-8'); _textdomain('phpmyadmin'); /** * Messages for phpMyAdmin. * * These messages are here for easy transition to Gettext. * You should not add any messages here, use instead gettext directly * in your template/PHP file. */ if (!function_exists('__')) { PMA_fatalError('Bad invocation!'); } /* Text direction for language */ if (in_array($GLOBALS['lang'], array('ar', 'fa', 'he', 'ur'))) { $GLOBALS['text_dir'] = 'rtl';
function loadConfig() { global $board, $config, $__ip, $debug, $__version; if (!isset($_SERVER['REMOTE_ADDR'])) { $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; } require 'inc/config.php'; if (file_exists('inc/instance-config.php')) { require 'inc/instance-config.php'; } if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { require $board['dir'] . '/config.php'; } if (!isset($__version)) { $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; } $config['version'] = $__version; if ($config['debug']) { if (!isset($debug)) { $debug = array('sql' => array(), 'purge' => array(), 'cached' => array()); $debug['start'] = microtime(true); } } date_default_timezone_set($config['timezone']); if (!isset($config['blotter'])) { $config['blotter'] = false; } if (!isset($config['post_url'])) { $config['post_url'] = $config['root'] . $config['file_post']; } if (!isset($config['referer_match'])) { $config['referer_match'] = '/^' . (preg_match($config['url_regex'], $config['root']) ? '' : 'https?:\\/\\/' . $_SERVER['HTTP_HOST']) . preg_quote($config['root'], '/') . '(' . str_replace('%s', '\\w+', preg_quote($config['board_path'], '/')) . '(' . preg_quote($config['file_index'], '/') . '|' . str_replace('%d', '\\d+', preg_quote($config['file_page'])) . ')?' . '|' . str_replace('%s', '\\w+', preg_quote($config['board_path'], '/')) . preg_quote($config['dir']['res'], '/') . str_replace('%d', '\\d+', preg_quote($config['file_page'], '/')) . '|' . preg_quote($config['file_mod'], '/') . '\\?\\/.+' . ')([#?](.+)?)?$/i'; } if (!isset($config['cookies']['path'])) { $config['cookies']['path'] =& $config['root']; } if (!isset($config['dir']['static'])) { $config['dir']['static'] = $config['root'] . 'static/'; } if (!isset($config['image_sticky'])) { $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; } if (!isset($config['image_locked'])) { $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; } if (!isset($config['image_bumplocked'])) { $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; } if (!isset($config['image_deleted'])) { $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; } if (!isset($config['image_zip'])) { $config['image_zip'] = $config['dir']['static'] . 'zip.png'; } if (!isset($config['uri_thumb'])) { $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; } elseif (isset($board['dir'])) { $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); } if (!isset($config['uri_img'])) { $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; } elseif (isset($board['dir'])) { $config['uri_img'] = sprintf($config['uri_img'], $board['dir']); } if (!isset($config['uri_stylesheets'])) { $config['uri_stylesheets'] = $config['root'] . 'stylesheets/'; } if (!isset($config['url_stylesheet'])) { $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; } if (!isset($config['url_javascript'])) { $config['url_javascript'] = $config['root'] . 'main.js'; } if ($config['root_file']) { chdir($config['root_file']); } if ($config['verbose_errors']) { error_reporting(E_ALL); ini_set('display_errors', 1); } // Keep the original address to properly comply with other board configurations if (!isset($__ip)) { $__ip = $_SERVER['REMOTE_ADDR']; } // ::ffff:0.0.0.0 if (preg_match('/^\\:\\:(ffff\\:)?(\\d+\\.\\d+\\.\\d+\\.\\d+)$/', $__ip, $m)) { $_SERVER['REMOTE_ADDR'] = $m[2]; } if (_setlocale(LC_ALL, $config['locale']) === false) { $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; $error('The specified locale (' . $config['locale'] . ') does not exist on your platform!'); } if (extension_loaded('gettext')) { bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard'); } if ($config['syslog']) { openlog('tinyboard', LOG_ODELAY, LOG_SYSLOG); } // open a connection to sysem logger if ($config['recaptcha']) { require_once 'inc/contrib/recaptcha/recaptchalib.php'; } if ($config['cache']['enabled']) { require_once 'inc/cache.php'; } }