本文整理汇总了PHP中locales类的典型用法代码示例。如果您正苦于以下问题:PHP locales类的具体用法?PHP locales怎么用?PHP locales使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了locales类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: body_attributes
public function body_attributes()
{
if (locales::is_rtl()) {
return 'class="rtl"';
}
return '';
}
开发者ID:shai,项目名称:gallery3,代码行数:7,代码来源:MY_View.php
示例2: head
static function head($theme)
{
if (count(locales::installed())) {
// Needed by the languages block
$theme->script("jquery.cookie.js");
}
return "";
}
开发者ID:brocki,项目名称:gallery3,代码行数:8,代码来源:user_theme.php
示例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);
}
}
开发者ID:eo04837,项目名称:gallery3,代码行数:10,代码来源:user.php
示例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);
}
}
开发者ID:CardinS2U,项目名称:gallery3,代码行数:14,代码来源:users.php
示例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"));
}
开发者ID:CardinS2U,项目名称:gallery3,代码行数:16,代码来源:admin_languages.php
示例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;
}
}
开发者ID:Okat,项目名称:gallery3,代码行数:16,代码来源:user_theme.php
示例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 -->";
}
}
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:47,代码来源:navcarousel_theme.php
示例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);
}
}
开发者ID:Okat,项目名称:gallery3,代码行数:17,代码来源:user_event.php
示例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;
}
开发者ID:brocki,项目名称:gallery3,代码行数:21,代码来源:user_block.php
示例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/>
开发者ID:ChrisRut,项目名称:gallery3,代码行数:31,代码来源:l10n_client.html.php
示例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;
}
开发者ID:CardinS2U,项目名称:gallery3,代码行数:15,代码来源:locales.php
示例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);
}
开发者ID:andyst,项目名称:gallery3,代码行数:19,代码来源:gallery_event.php
示例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);
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:8,代码来源:Locales_Helper_Test.php
示例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();
}
}
开发者ID:shai,项目名称:gallery3,代码行数:69,代码来源:l10n_client.php
示例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)) {
开发者ID:CardinS2U,项目名称:gallery3,代码行数:31,代码来源:admin_languages.html.php
示例16: _languages_form
private function _languages_form()
{
$all_locales = locales::available();
$installed_locales = locales::installed();
$form = new Forge("admin/languages/save", "", "post", array("id" => "gLanguageSettingsForm"));
$group = $form->group("choose_language")->label(t("Language settings"));
$group->dropdown("locale")->options($installed_locales)->selected(module::get_var("gallery", "default_locale"))->label(t("Default language"))->rules('required');
$installation_options = array();
foreach ($all_locales as $code => $display_name) {
$installation_options[$code] = array($display_name, isset($installed_locales->{$code}));
}
$group->checklist("installed_locales")->label(t("Installed Languages"))->options($installation_options)->rules("required");
$group->submit("save")->value(t("Save settings"));
return $form;
}
开发者ID:hiwilson,项目名称:gallery3,代码行数:15,代码来源:admin_languages.php
示例17: get
static function get($block_id)
{
$block = new Block();
switch ($block_id) {
case "welcome":
$block->css_id = "g-welcome";
$block->title = t("Welcome to Gallery 3");
$block->content = new View("admin_block_welcome.html");
break;
case "photo_stream":
$block->css_id = "g-photo-stream";
$block->title = t("Photo stream");
$block->content = new View("admin_block_photo_stream.html");
$block->content->photos = ORM::factory("item")->where("type", "=", "photo")->order_by("created", "DESC")->find_all(10);
break;
case "log_entries":
$block->css_id = "g-log-entries";
$block->title = t("Log entries");
$block->content = new View("admin_block_log_entries.html");
$block->content->entries = ORM::factory("log")->order_by(array("timestamp" => "DESC", "id" => "DESC"))->find_all(5);
break;
case "stats":
$block->css_id = "g-stats";
$block->title = t("Gallery stats");
$block->content = new View("admin_block_stats.html");
$block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all();
$block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
break;
case "platform_info":
$block->css_id = "g-platform";
$block->title = t("Platform information");
$block->content = new View("admin_block_platform.html");
break;
case "project_news":
$block->css_id = "g-project-news";
$block->title = t("Gallery project news");
$block->content = new View("admin_block_news.html");
$block->content->feed = feed::parse("http://gallery.menalto.com/node/feed", 3);
break;
case "block_adder":
$block->css_id = "g-block-adder";
$block->title = t("Dashboard content");
$block->content = gallery_block::get_add_block_form();
break;
case "language":
$locales = locales::installed();
if (count($locales) > 1) {
foreach ($locales as $locale => $display_name) {
$locales[$locale] = SafeString::of_safe_html($display_name);
}
$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) locales::cookie_locale();
} else {
$block = "";
}
break;
case "upgrade_checker":
$block = new Block();
$block->css_id = "g-upgrade-available-block";
$block->title = t("Check for Gallery upgrades");
$block->content = new View("upgrade_checker_block.html");
$block->content->version_info = upgrade_checker::version_info();
$block->content->auto_check_enabled = upgrade_checker::auto_check_enabled();
$block->content->new_version = upgrade_checker::get_upgrade_message();
}
return $block;
}
开发者ID:Joe7,项目名称:gallery3,代码行数:71,代码来源:gallery_block.php
示例18: gallery_ready
/**
* Initialization.
*/
static function gallery_ready()
{
user::load_user();
locales::set_request_locale();
}
开发者ID:CardinS2U,项目名称:gallery3,代码行数:8,代码来源:gallery_event.php
示例19: fetch_updates
/**
* Fetches translations for l10n messages. Must be called repeatedly
* until 0 is returned (which is a countdown indicating progress).
*
* @param $num_fetched in/out parameter to specify which batch of
* messages to fetch translations for.
* @return The number of messages for which we didn't fetch
* translations for.
*/
static function fetch_updates(&$num_fetched)
{
$request = new stdClass();
$request->locales = array();
$request->messages = new stdClass();
$locales = locales::installed();
foreach ($locales as $locale => $locale_data) {
$request->locales[] = $locale;
}
// See the server side code for how we arrive at this
// number as a good limit for #locales * #messages.
$max_messages = 2000 / count($locales);
$num_messages = 0;
$rows = db::build()->select("key", "locale", "revision", "translation")->from("incoming_translations")->order_by("key")->limit(1000000)->offset($num_fetched)->execute();
$num_remaining = $rows->count();
foreach ($rows as $row) {
if (!isset($request->messages->{$row->key})) {
if ($num_messages >= $max_messages) {
break;
}
$request->messages->{$row->key} = 1;
$num_messages++;
}
if (!empty($row->revision) && !empty($row->translation) && isset($locales[$row->locale])) {
if (!is_object($request->messages->{$row->key})) {
$request->messages->{$row->key} = new stdClass();
}
$request->messages->{$row->key}->{$row->locale} = (int) $row->revision;
}
$num_fetched++;
$num_remaining--;
}
// @todo Include messages from outgoing_translations?
if (!$num_messages) {
return $num_remaining;
}
$request_data = json_encode($request);
$url = self::_server_url("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 $num_remaining;
}
$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("key", "=", $key)->where("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("key", "=", $key)->where("locale", "=", "root")->find();
$entry->key = $key;
$entry->message = $root_entry->message;
$entry->locale = $locale;
}
$entry->revision = $revision;
$entry->translation = $translation;
$entry->save();
}
return $num_remaining;
}
开发者ID:Joe7,项目名称:gallery3,代码行数:91,代码来源:l10n_client.php
示例20: create_pending_request
static function create_pending_request($form)
{
$email_verification = module::get_var("registration", "email_verification");
$user = ORM::factory("pending_user");
$user->name = $form->register_user->inputs["name"]->value;
$user->full_name = $form->register_user->inputs["full_name"]->value;
$user->email = $form->register_user->inputs["email"]->value;
$user->url = $form->register_user->inputs["url"]->value;
$user->request_date = time();
// added by Shad Laws, v2
$user->locale = locales::locale_from_http_request() ? locales::locale_from_http_request() : module::get_var("gallery", "default_locale");
// sets default locale based on browser
if (!$email_verification) {
$user->state = 1;
}
$user->hash = md5(rand());
$user->save();
return $user;
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:19,代码来源:register.php
注:本文中的locales类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论