function includeLocale($lang) { global $langs; if (!$lang || !array_key_exists($lang, $langs)) { $lang = getUserLang(); } setlocale(LC_ALL, $langs[$lang][0]); bind_textdomain_codeset("messages", "UTF-8"); bindtextdomain("messages", "../locales"); textdomain("messages"); }
<?php /* OpenRailwayMap Copyright (C) 2012 Alexander Matheisen This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See http://wiki.openstreetmap.org/wiki/OpenRailwayMap for details. */ require_once "functions.php"; $format = $_GET['format']; $callback = $_GET['callback']; header("Content-Type: text/plain; charset=UTF-8"); if ($format == "json") { $jsonData = json_encode(array('lang' => getUserLang())); // JSONP request? if (isset($callback)) { echo $callback . '(' . $jsonData . ')'; } else { echo $jsonData; } } else { echo getUserLang(); }
<?php /* OpenRailwayMap Copyright (C) 2012 Alexander Matheisen This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See http://wiki.openstreetmap.org/wiki/OpenRailwayMap for details. */ require_once "api/functions.php"; if (isset($_GET['lang']) && array_key_exists($_GET['lang'], $langs)) { $lang = $_GET['lang']; } else { $lang = getUserLang(); } includeLocale($lang); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $lang; ?> " lang="<?php echo $lang; ?> "> <head> <title>OpenRailwayMap</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="content-language" content="<?php echo $lang; ?> " />
$app->config(array('debug' => true, 'cookies.lifetime' => '1 day', 'cookies.secret_key' => 'b4924c3579e2850a6fad8597da7ad24bf43ab78e')); require 'vendor/DateTimeFileWriter.php'; $app->getLog()->setEnabled(true); $app->getLog()->setLevel(\Slim\Log::DEBUG); $app->getLog()->setWriter(new \Slim\Extras\Log\DateTimeFileWriter(array('path' => './data', 'name_format' => 'Y-m-d'))); $app->getLog()->info($appname . ' ' . $appversion . ': Running in debug mode.'); error_reporting(E_ALL); } # Init app globals $globalSettings = array(); $globalSettings['appname'] = $appname; $globalSettings['version'] = $appversion; $globalSettings['sep'] = ' :: '; # Find the user language, either one of the allowed languages or # English as a fallback. $globalSettings['lang'] = getUserLang($allowedLangs, $fallbackLang); $globalSettings['l10n'] = new L10n($globalSettings['lang']); $globalSettings['langa'] = $globalSettings['l10n']->langa; $globalSettings['langb'] = $globalSettings['l10n']->langb; # Init admin settings with std values, for upgrades or db errors $globalSettings[CALIBRE_DIR] = ''; $globalSettings[DB_VERSION] = DB_SCHEMA_VERSION; $globalSettings[KINDLE] = 0; $globalSettings[KINDLE_FROM_EMAIL] = ''; $globalSettings[THUMB_GEN_CLIPPED] = 1; $globalSettings[PAGE_SIZE] = 30; $globalSettings[DISPLAY_APP_NAME] = $appname; $globalSettings[MAILER] = Mailer::MAIL; $globalSettings[SMTP_USER] = ''; $globalSettings[SMTP_PASSWORD] = ''; $globalSettings[SMTP_SERVER] = '';