本文整理汇总了PHP中setlocale函数的典型用法代码示例。如果您正苦于以下问题:PHP setlocale函数的具体用法?PHP setlocale怎么用?PHP setlocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setlocale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST);
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} else {
if ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
}
示例2: __construct
/**
* Constructor
*
* @return void
*/
public function __construct($caller)
{
setlocale(LC_MONETARY, 'en_US.UTF-8');
$logPath = Config::get('log_path', PATH_APP . DS . 'logs');
$this->logFile = $logPath . DS . 'cart.log';
$this->caller = $caller;
}
示例3: translate
function translate($lang, $test = 0)
{
global $LOCALE_PATH;
putenv("LANGUAGE={$lang}");
bindtextdomain("zarafa", "{$LOCALE_PATH}");
if (STORE_SUPPORTS_UNICODE == false) {
bind_textdomain_codeset('zarafa', "windows-1252");
} else {
bind_textdomain_codeset('zarafa', "utf-8");
}
textdomain('zarafa');
setlocale(LC_ALL, $lang);
$trans_array["Sent Items"] = _("Sent Items");
$trans_array["Outbox"] = _("Outbox");
$trans_array["Deleted Items"] = _("Deleted Items");
$trans_array["Inbox"] = _("Inbox");
$trans_array["Calendar"] = _("Calendar");
$trans_array["Contacts"] = _("Contacts");
$trans_array["Drafts"] = _("Drafts");
$trans_array["Journal"] = _("Journal");
$trans_array["Notes"] = _("Notes");
$trans_array["Tasks"] = _("Tasks");
$trans_array["Junk E-mail"] = _("Junk E-mail");
return $trans_array;
}
示例4: _fetch_fireeagle_positions
private function _fetch_fireeagle_positions($fireeagle_access_key, $fireeagle_access_secret)
{
$position = array();
require_once MIDCOM_ROOT . '/external/fireeagle.php';
$fireeagle = new FireEagle($this->_config->get('fireeagle_consumer_key'), $this->_config->get('fireeagle_consumer_secret'), $fireeagle_access_key, $fireeagle_access_secret);
// Note: this must be C so we get floats correctly from JSON. See http://bugs.php.net/bug.php?id=41403
setlocale(LC_NUMERIC, 'C');
$user_data = $fireeagle->user();
if (!$user_data || !$user_data->user || empty($user_data->user->location_hierarchy)) {
return $position;
}
$best_position = $user_data->user->location_hierarchy[0];
switch ($best_position->level_name) {
case 'exact':
$position['accuracy'] = 10;
break;
case 'postal':
$position['accuracy'] = 20;
break;
case 'city':
$position['accuracy'] = 30;
break;
default:
$position['accuracy'] = 60;
break;
}
$position['latitude'] = $best_position->latitude;
$position['longitude'] = $best_position->longitude;
$position['date'] = strtotime($best_position->located_at);
return $position;
}
示例5: localeDateTime
/**
* Returns the date time in a particular format. Takes the locale into
* account.
*
* @param string|\DateTime $dateTime
* @param string $format
*
* @return string Formatted date and time
*/
public function localeDateTime($dateTime, $format = '%B %e, %Y %H:%M')
{
if (!$dateTime instanceof \DateTime) {
$dateTime = new \DateTime($dateTime);
}
// Check for Windows to find and replace the %e modifier correctly
// @see: http://php.net/strftime
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\\1%#d', $format);
}
// According to http://php.net/manual/en/function.setlocale.php manual
// if the second parameter is "0", the locale setting is not affected,
// only the current setting is returned.
$result = setlocale(LC_ALL, 0);
if ($result === false) {
// This shouldn't occur, but.. Dude!
// You ain't even got locale or English on your platform??
// Various things we could do. We could fail miserably, but a more
// graceful approach is to use the datetime to display a default
// format
$this->app['logger.system']->error('No valid locale detected. Fallback on DateTime active.', ['event' => 'system']);
return $dateTime->format('Y-m-d H:i:s');
} else {
$timestamp = $dateTime->getTimestamp();
return strftime($format, $timestamp);
}
}
示例6: Serial
/**
* Constructor. Perform some checks about the OS and setserial
*
* @return phpSerial
*/
function Serial()
{
setlocale(LC_ALL, "en_US");
$sysname = php_uname();
if (substr($sysname, 0, 5) === "Linux") {
$this->_os = "linux";
if ($this->_exec("stty --version") === 0) {
register_shutdown_function(array($this, "deviceClose"));
} else {
trigger_error("No stty availible, unable to run.", E_USER_ERROR);
}
} elseif (substr($sysname, 0, 6) === "Darwin") {
$this->_os = "osx";
// We know stty is available in Darwin.
// stty returns 1 when run from php, because "stty: stdin isn't a
// terminal"
// skip this check
// if($this->_exec("stty") === 0)
// {
register_shutdown_function(array($this, "deviceClose"));
// }
// else
// {
// trigger_error("No stty availible, unable to run.", E_USER_ERROR);
// }
} elseif (substr($sysname, 0, 7) === "Windows") {
$this->_os = "windows";
register_shutdown_function(array($this, "deviceClose"));
} else {
trigger_error("Host OS is neither osx, linux nor windows, unable tu run.", E_USER_ERROR);
exit;
}
}
示例7: zeichne_beitrag
function zeichne_beitrag($param)
{
$Erster = $param['Erster'];
$ForumId = $param['ForumId'];
$BeitragId = $param['BeitragId'];
$Autor = $param['Autor'];
$AutorURL = rawurlencode($Autor);
$StempelLetzter = $param['StempelLetzter'];
$Thema = $param['Thema'];
$Inhalt = $param['Inhalt'];
$Egl = $param['Egl'];
$Atavar = $param['Atavar'];
setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge');
$datum = strftime("%d.%b.%Y", $StempelLetzter);
$zeit = date("H.i:s", $StempelLetzter);
if ($Erster) {
echo " <tr>\n <th class=\"ueber\" align=\"center\" width=\"100%\" colspan=\"2\">{$Thema}</th>\n </tr>\n";
}
echo " <tr>\n <td colspan=\"2\">\n <table class=\"beitrag\">\n <tr>\n <th class=\"ueber\" align=\"left\" colspan=\"2\"><a href=\"mitglieder-profil.php?alias={$AutorURL}\">{$Autor}</a></th>\n <th class=\"ueber\" align=\"right\">{$datum} {$zeit}</th>\n </tr>\n <tr>\n";
if ($Atavar > -1) {
echo " <td class=\"col-dunkel\" valign=\"top\">\n <div class=\"atavar\">\n <img src=\"atavar-ausgeben.php?atavar={$Atavar}\">\n </div>\n </td>\n <td class=\"col-hell\" valign=\"top\" colspan=\"2\" width=\"100%\">{$Inhalt}</td>\n";
} else {
echo " <td class=\"col-hell\" valign=\"top\" colspan=\"3\" width=\"100%\">{$Inhalt}</td>\n";
}
echo " </tr>\n </table>\n </td>\n </tr>\n";
// Die Antwort Zeile
if ($Egl) {
echo " <tr>\n <td><font size=\"-1\"><input type=\"radio\" name=\"eltern\" value=\"{$BeitragId}\"";
if ($Erster) {
echo ' checked';
}
echo ">Antworten auf diesen Beitrag</font></td>\n <td align=\"right\"><font size=\"-1\"><button type=\"submit\" name=\"zid\" value=\"{$BeitragId}\">zitieren</button></font></td>\n </tr>\n";
}
}
示例8: init
public function init($configFile)
{
if (!file_exists($configFile) || !is_file($configFile)) {
die("Missing main configuration file");
}
//$x = setlocale(LC_TIME, 'ru_RU.CP1251', 'ru_RU.cp1251', 'Russian_Russia.1251');
$x = setlocale(LC_ALL, 'rus_RUS.65001', 'rus_RUS.65001', 'Russian_Russia.65001');
$xml = simplexml_load_file($configFile);
foreach ($xml->module as $module) {
$configuration = new ConfigParameter($module->asXML());
$class = $configuration->get('class');
if (!$class) {
die("Module has no class");
}
$module_id = $configuration->get('id');
if (!$module_id) {
die("Module has no ID");
}
if (Project::exists($module_id)) {
// TODO:: write to log file
//die("Module id already busy:".$module_id);
}
$module = new $class();
$module->initialize($configuration);
if ($module->setToRegistry() === true) {
Project::set($module_id, $module);
}
unset($module);
}
}
示例9: getSelect
public static function getSelect($menu)
{
date_default_timezone_set('America/Bogota');
setlocale(LC_ALL, 'es_ES.UTF-8');
$base = bu('programacion');
$hoy = mktime(0, 0, 0, date('m'), date('j'), date('Y'));
$html = '';
$manana = $hoy + 86400;
$ya = false;
$ruri = Yii::app()->request->requestUri;
$html .= '<select name="dia_programacion" id="dia_programacion">';
foreach ($menu as $item) {
$selected = '';
$url = $base . '?dia=' . date('j', $item) . '&mes=' . date('m', $item) . '&anio=' . date('Y', $item);
if (!$ya) {
if ($url == $ruri) {
$selected = " selected='selected'";
$ya = true;
} elseif ($item >= $hoy && $item < $manana) {
$selected = " selected='selected'";
} else {
$selected = '';
}
}
$html .= '<option value="' . $url . '"' . $selected . '>';
$html .= ucfirst(strftime("%A", $item)) . ' ' . strftime("%e", $item);
$html .= '</option>';
}
$html .= '</select>';
return $html;
}
示例10: parserAction
/**
* @Route("/admin/parser")
* @Method("GET")
* @Template()
*/
public function parserAction()
{
set_time_limit(0);
$rootDir = $this->get('kernel')->getRootDir();
$content = file_get_contents(realpath($rootDir . '/../docs/google-groups-posts.bkp.html'));
$crawler = new Crawler($content);
$subjectFilterPrefix = 'pergunta';
$em = $this->get('doctrine')->getManager();
$crawler->filter('body > table > tbody > tr > td > div > div > div:first-child')->each(function (Crawler $node, $i) use(&$subjectFilterPrefix, $em) {
$subject = $node->filter('a')->first();
$author = $node->filter('div:first-child > div')->attr('data-name');
$time = $node->filter('div')->last()->children()->attr('title');
setlocale(LC_ALL, NULL);
setlocale(LC_ALL, 'pt_BR');
if (substr(strtolower(utf8_decode($subject->text())), 0, strlen($subjectFilterPrefix)) == $subjectFilterPrefix) {
$timeParts = explode(',', utf8_decode($time));
$timeParsed = strptime(end($timeParts), '%d de %B de %Y %Hh%Mmin%Ss');
$createdAt = new \DateTime(date('Y-m-d h:i:s', mktime($timeParsed['tm_hour'], $timeParsed['tm_min'], $timeParsed['tm_sec'], 1, $timeParsed['tm_yday'] + 1, $timeParsed['tm_year'] + 1900)));
$entity = $em->getRepository('CekurteZCPEBundle:Parser')->findOneBy(array('subject' => utf8_decode($subject->text())));
if (!$entity instanceof Parser) {
$parser = new Parser();
$parser->setSubject(utf8_decode($subject->text()))->setUrl($subject->attr('href'))->setAuthor(utf8_decode($author))->setCreatedAt($createdAt);
$em->persist($parser);
$em->flush();
}
}
});
return array();
}
示例11: index
public function index()
{
Carbon::setLocale('de');
setlocale(LC_TIME, 'de_DE.utf8');
$myTipps = Tipp::join('matches', 'tipps.match_id', '=', 'matches.id')->join('clubs as homeclub', 'matches.home_id', '=', 'homeclub.id')->join('clubs as awayclub', 'matches.away_id', '=', 'awayclub.id')->select('matches.home_goals as erg1', 'matches.away_goals as erg2', 'matches.date', 'tipps.*', 'homeclub.club as home', 'awayclub.club as away')->where('tipps.user_id', '=', Auth::id())->orderBy('date')->get();
return view('pages.tipps', compact('myTipps'));
}
示例12: testExtract
/**
* Tests ability to extract EXIF data without errors. Does not test data
* for validity.
*/
public function testExtract()
{
$fixture = __DIR__ . '/../Fixtures/img_exif.jpg';
setlocale(LC_ALL, 'de_DE');
self::$_data = self::$_exif->getData($fixture);
$this->assertInternalType('array', self::$_data);
}
示例13: set_language
function set_language()
{
global $amp_conf, $db;
$nt = notifications::create($db);
if (extension_loaded('gettext')) {
$nt->delete('core', 'GETTEXT');
if (php_sapi_name() !== 'cli') {
if (empty($_COOKIE['lang']) || !preg_match('/^[\\w\\._@-]+$/', $_COOKIE['lang'], $matches)) {
$lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
if (empty($_COOKIE['lang'])) {
setcookie("lang", $lang);
}
} else {
preg_match('/^([\\w\\._@-]+)$/', $_COOKIE['lang'], $matches);
$lang = !empty($matches[1]) ? $matches[1] : 'en_US';
}
$_COOKIE['lang'] = $lang;
} else {
$lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
}
putenv('LC_ALL=' . $lang);
putenv('LANG=' . $lang);
putenv('LANGUAGE=' . $lang);
setlocale(LC_ALL, $lang);
bindtextdomain('amp', $amp_conf['AMPWEBROOT'] . '/admin/i18n');
bind_textdomain_codeset('amp', 'utf8');
textdomain('amp');
return $lang;
}
$nt->add_warning('core', 'GETTEXT', _("Gettext is not installed"), _("Please install gettext so that the PBX can properly translate itself"), 'https://www.gnu.org/software/gettext/');
return 'en_US';
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$piwikLanguages = \Piwik\Plugins\LanguagesManager\API::getInstance()->getAvailableLanguages();
$aliasesUrl = 'https://raw.githubusercontent.com/unicode-cldr/cldr-core/master/supplemental/aliases.json';
$aliasesData = Http::fetchRemoteFile($aliasesUrl);
$aliasesData = json_decode($aliasesData, true);
$aliasesData = $aliasesData['supplemental']['metadata']['alias']['languageAlias'];
$writePath = Filesystem::getPathToPiwikRoot() . '/plugins/Intl/lang/%s.json';
foreach ($piwikLanguages as $langCode) {
if ($langCode == 'dev') {
continue;
}
$requestLangCode = $transformedLangCode = $this->transformLangCode($langCode);
if (array_key_exists($requestLangCode, $aliasesData)) {
$requestLangCode = $aliasesData[$requestLangCode]['_replacement'];
}
// fix some locales
$localFixes = array('pt' => 'pt-PT', 'pt-br' => 'pt', 'zh-cn' => 'zh-Hans', 'zh-tw' => 'zh-Hant');
if (array_key_exists($langCode, $localFixes)) {
$requestLangCode = $localFixes[$langCode];
}
setlocale(LC_ALL, $langCode);
$translations = array();
$this->fetchLanguageData($output, $transformedLangCode, $requestLangCode, $translations);
$this->fetchTerritoryData($output, $transformedLangCode, $requestLangCode, $translations);
$this->fetchCalendarData($output, $transformedLangCode, $requestLangCode, $translations);
$this->fetchLayoutDirection($output, $transformedLangCode, $requestLangCode, $translations);
$this->fetchUnitData($output, $transformedLangCode, $requestLangCode, $translations);
$this->fetchNumberFormattingData($output, $transformedLangCode, $requestLangCode, $translations);
ksort($translations['Intl']);
file_put_contents(sprintf($writePath, $langCode), json_encode($translations, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
}
}
示例15: smarty_modifier_locale
function smarty_modifier_locale($stream, $locale)
{
setlocale("LC_ALL", $locale);
setlocale("LC_TIME", $locale);
setlocale("LC_LANG", $locale);
return $stream;
}