本文整理汇总了PHP中locales类的典型用法代码示例。如果您正苦于以下问题:PHP locales类的具体用法?PHP locales怎么用?PHP locales使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了locales类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: body_attributes
public function body_attributes()
{
if (locales::is_rtl()) {
return 'class="rtl"';
}
return '';
}
示例2: head
static function head($theme)
{
if (count(locales::installed())) {
// Needed by the languages block
$theme->script("jquery.cookie.js");
}
return "";
}
示例3: _add_locale_dropdown
private static function _add_locale_dropdown(&$form, $user = null)
{
$locales = locales::installed();
if (count($locales) > 1) {
// Put "none" at the first position in the array
$locales = array_merge(array("" => t("« none »")), $locales);
$selected_locale = $user && $user->locale ? $user->locale : "";
$form->dropdown("locale")->label(t("Language Preference"))->options($locales)->selected($selected_locale);
}
}
示例4: _add_locale_dropdown
/** @todo combine with Admin_Users_Controller::_add_locale_dropdown */
private function _add_locale_dropdown(&$form, $user = null)
{
$locales = locales::installed();
foreach ($locales as $locale => $display_name) {
$locales[$locale] = SafeString::of_safe_html($display_name);
}
if (count($locales) > 1) {
// Put "none" at the first position in the array
$locales = array_merge(array("" => t("« none »")), $locales);
$selected_locale = $user && $user->locale ? $user->locale : "";
$form->dropdown("locale")->label(t("Language Preference"))->options($locales)->selected($selected_locale);
}
}
示例5: save
public function save()
{
access::verify_csrf();
locales::update_installed($this->input->post("installed_locales"));
$installed_locales = array_keys(locales::installed());
$new_default_locale = $this->input->post("default_locale");
if (!in_array($new_default_locale, $installed_locales)) {
if (!empty($installed_locales)) {
$new_default_locale = $installed_locales[0];
} else {
$new_default_locale = "en_US";
}
}
module::set_var("gallery", "default_locale", $new_default_locale);
print json_encode(array("result" => "success"));
}
示例6: sidebar_blocks
static function sidebar_blocks($theme)
{
$locales = locales::installed();
foreach ($locales as $locale => $display_name) {
$locales[$locale] = SafeString::of_safe_html($display_name);
}
if (count($locales) > 1) {
$block = new Block();
$block->css_id = "gUserLanguageBlock";
$block->title = t("Select Language Preference");
$block->content = new View("user_languages_block.html");
$block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
$block->content->selected = (string) user::cookie_locale();
return $block;
}
}
示例7: head
static function head($theme)
{
if ($theme->page_type == "item") {
if (locales::is_rtl()) {
$rtl_support = "rtl: true,\n";
} else {
$rtl_support = "rtl: false,\n";
}
$carouselwidth = module::get_var("navcarousel", "carouselwidth", "600");
if ($carouselwidth == 0) {
$carouselwidth = "100%";
$containerwidth = "";
} else {
$carouselwidth = $carouselwidth . "px";
$containerwidth = ".jcarousel-skin-tango .jcarousel-container-horizontal {\n\n width: " . $carouselwidth . ";\n\n }\n";
}
$thumbsize = module::get_var("navcarousel", "thumbsize", "50");
$theme->script("jquery.jcarousel.min.js");
$theme->css("skin.css");
$showelements = module::get_var("navcarousel", "showelements", "7");
$childcount = $theme->item->parent()->viewable()->children_count();
$itemoffset = intval(floor($showelements / 2));
if ($childcount <= $showelements) {
$itemoffset = 1;
} else {
$itempos = $theme->item->parent()->get_position($theme->item);
$itemoffset = $itempos - $itemoffset;
if ($itemoffset < 1) {
$itemoffset = 1;
}
if ($itemoffset + $showelements > $childcount) {
$itemoffset = $childcount - $showelements + 1;
}
}
if (module::get_var("navcarousel", "noajax", false)) {
$ajaxhandler = "";
} else {
$ajaxhandler = "itemLoadCallback: navcarousel_itemLoadCallback,\n";
}
if (module::get_var("navcarousel", "showondomready", false)) {
$onwinload = "";
} else {
$onwinload = "});\n\n \$(window).load(function () {\n";
}
return "\n<!-- Navcaoursel -->\n <style type=\"text/css\">\n\n " . $containerwidth . "\n .jcarousel-skin-tango .jcarousel-clip-horizontal {\n\n width: " . $carouselwidth . ";\n\n height: " . ($thumbsize + 25) . "px;\n\n }\n\n .jcarousel-skin-tango .jcarousel-item {\n\n width: " . ($thumbsize + 25) . "px;\n\n height: " . ($thumbsize + 25) . "px;\n\n }\n\n #navcarousel-loader {\n\n height: " . ($thumbsize + 25) . "px;\n\n }\n\n .jcarousel-skin-tango .jcarousel-next-horizontal {\n top: " . intval(floor($thumbsize / 2.8)) . "px;\n }\n .jcarousel-skin-tango .jcarousel-prev-horizontal {\n top: " . intval(floor($thumbsize / 2.8)) . "px;\n }\n </style>\n\n <script type=\"text/javascript\">\n\n jQuery(document).ready(function() {\n\n jQuery('#navcarousel').jcarousel({\n\n " . $ajaxhandler . "\n itemFallbackDimension: " . ($thumbsize + 25) . ",\n\n start: " . $itemoffset . ",\n\n size: " . $childcount . ",\n\n visible: " . $showelements . ",\n\n " . $rtl_support . "\n scroll: " . module::get_var("navcarousel", "scrollsize", "7") . "\n\n });\n\n " . $onwinload . "\n \$(\".jcarousel-prev-horizontal\").css(\"visibility\", \"visible\");\n\n \$(\".jcarousel-next-horizontal\").css(\"visibility\", \"visible\");\n\n \$(\"#navcarousel\").css(\"visibility\", \"visible\");\n\n \$(\"#navcarousel-wrapper\").css(\"background\", \"none\");\n\n \$(\"#navcarousel-wrapper\").css(\"float\", \"left\");\n\n });\n\n </script>\n\n <!-- Navcaoursel -->";
}
}
示例8: set_request_locale
static function set_request_locale()
{
// 1. Check the session specific preference (cookie)
$locale = user::cookie_locale();
// 2. Check the user's preference
if (!$locale) {
$locale = user::active()->locale;
}
// 3. Check the browser's / OS' preference
if (!$locale) {
$locale = locales::locale_from_http_request();
}
// If we have any preference, override the site's default locale
if ($locale) {
I18n::instance()->locale($locale);
}
}
示例9: get
static function get($block_id, $theme)
{
$block = "";
switch ($block_id) {
case "language":
$locales = locales::installed();
foreach ($locales as $locale => $display_name) {
$locales[$locale] = SafeString::of_safe_html($display_name);
}
if (count($locales) > 1) {
$block = new Block();
$block->css_id = "g-user-language-block";
$block->title = t("Language Preference");
$block->content = new View("user_languages_block.html");
$block->content->installed_locales = array_merge(array("" => t("« none »")), $locales);
$block->content->selected = (string) user::cookie_locale();
}
break;
}
return $block;
}
示例10: if
<? if (!Input::instance()->get('show_all_l10n_messages')): ?>
<a style="background-color:#fff" href="<?php
echo url::site("admin/languages?show_all_l10n_messages=1");
?>
"><?php
echo t("(Show all)");
?>
</a>
<? endif; ?>
</h2></div>
<div class="label source"><h2><?php
echo t("Source");
?>
</div>
<div class="label translation"><h2><?php
echo t("Translation to %language", array("language" => locales::display_name()));
?>
</h2></div>
</div>
<div id="l10n-client-string-select">
<ul class="string-list">
<? foreach ($string_list as $string): ?>
<li class="<?php
echo $string["translation"] === "" ? "untranslated" : "translated";
?>
">
<? if (is_array($string["source"])): ?>
[one] - <?php
echo $string["source"]["one"];
?>
<br/>
示例11: cookie_locale
static function cookie_locale()
{
$cookie_data = Input::instance()->cookie("g_locale");
$locale = null;
if ($cookie_data) {
if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)\$/", trim($cookie_data), $matches)) {
$requested_locale = $matches[1];
$installed_locales = locales::installed();
if (isset($installed_locales[$requested_locale])) {
$locale = $requested_locale;
}
}
}
return $locale;
}
示例12: show_user_profile
static function show_user_profile($data)
{
$v = new View("user_profile_info.html");
$fields = array("name" => t("Name"), "locale" => t("Language Preference"), "email" => t("Email"), "full_name" => t("Full name"), "url" => "Web site");
if (!$data->user->guest) {
$fields = array("name" => t("Name"), "full_name" => t("Full name"), "url" => "Web site");
}
$v->user_profile_data = array();
foreach ($fields as $field => $label) {
if (!empty($data->user->{$field})) {
$value = $data->user->{$field};
if ($field == "locale") {
$value = locales::display_name($value);
}
$v->user_profile_data[(string) $label] = $value;
}
}
$data->content[] = (object) array("title" => t("User information"), "view" => $v);
}
示例13: locale_from_http_request_prefer_inexact_same_language_match_over_exact_other_language_match_test
public function locale_from_http_request_prefer_inexact_same_language_match_over_exact_other_language_match_test()
{
locales::update_installed(array("de_DE", "ar_AR", "fa_IR", "he_IL", "en_US"));
// Accept-Language header from Firefox 3.5/Ubuntu
$_SERVER["HTTP_ACCEPT_LANGUAGE"] = "he,en-us;q=0.9,de-ch;q=0.5,en;q=0.3";
$locale = locales::locale_from_http_request();
$this->assert_equal("he_IL", $locale);
}
示例14: fetch_updates
/**
* @return an array of messages that will be written to the task log
*/
static function fetch_updates()
{
$request->locales = array();
$request->messages = new stdClass();
$locales = locales::installed();
foreach ($locales as $locale => $locale_data) {
$request->locales[] = $locale;
}
// @todo Batch requests (max request size)
foreach (Database::instance()->select("key", "locale", "revision", "translation")->from("incoming_translations")->get()->as_array() as $row) {
if (!isset($request->messages->{$row->key})) {
$request->messages->{$row->key} = 1;
}
if (!empty($row->revision) && !empty($row->translation)) {
if (!is_object($request->messages->{$row->key})) {
$request->messages->{$row->key} = new stdClass();
}
$request->messages->{$row->key}->{$row->locale} = $row->revision;
}
}
// @todo Include messages from outgoing_translations?
$request_data = json_encode($request);
$url = self::_server_url() . "?q=translations/fetch";
list($response_data, $response_status) = remote::post($url, array("data" => $request_data));
if (!remote::success($response_status)) {
throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED " . $response_status);
}
if (empty($response_data)) {
return array(t("Translations fetch request resulted in an empty response"));
}
$response = json_decode($response_data);
// Response format (JSON payload):
// [{key:<key_1>, translation: <JSON encoded translation>, rev:<rev>, locale:<locale>},
// {key:<key_2>, ...}
// ]
foreach ($response as $message_data) {
// @todo Better input validation
if (empty($message_data->key) || empty($message_data->translation) || empty($message_data->locale) || empty($message_data->rev)) {
throw new Exception("@todo TRANSLATIONS_FETCH_REQUEST_FAILED: Invalid response data");
}
$key = $message_data->key;
$locale = $message_data->locale;
$revision = $message_data->rev;
$translation = json_decode($message_data->translation);
if (!is_string($translation)) {
// Normalize stdclass to array
$translation = (array) $translation;
}
$translation = serialize($translation);
// @todo Should we normalize the incoming_translations table into messages(id, key, message)
// and incoming_translations(id, translation, locale, revision)? Or just allow
// incoming_translations.message to be NULL?
$locale = $message_data->locale;
$entry = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => $locale))->find();
if (!$entry->loaded) {
// @todo Load a message key -> message (text) dict into memory outside of this loop
$root_entry = ORM::factory("incoming_translation")->where(array("key" => $key, "locale" => "root"))->find();
$entry->key = $key;
$entry->message = $root_entry->message;
$entry->locale = $locale;
}
$entry->revision = $revision;
$entry->translation = $translation;
$entry->save();
}
}
示例15: t
echo t("Translating Gallery");
?>
</h3>
<p><?php
echo t("Follow these steps to begin translating Gallery.");
?>
</p>
<ul>
<li><?php
echo t("Make sure the target language is installed and up to date (check above).");
?>
</li>
<li><?php
echo t("Make sure you have selected the right target language (currently %default_locale).", array("default_locale" => locales::display_name()));
?>
</li>
<li><?php
echo t("Start the translation mode and the translation interface will appear at the bottom of each Gallery page.");
?>
</li>
</ul>
<a href="<?php
echo url::site("l10n_client/toggle_l10n_mode?csrf=" . access::csrf_token());
?>
"
class="g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-power"></span>
<?php
if (Session::instance()->get("l10n_mode", false)) {