本文整理汇总了PHP中locale::get_i18n方法的典型用法代码示例。如果您正苦于以下问题:PHP locale::get_i18n方法的具体用法?PHP locale::get_i18n怎么用?PHP locale::get_i18n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类locale
的用法示例。
在下文中一共展示了locale::get_i18n方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: site
/**
* Site Settings
*/
function site()
{
$this->template->content = new View('admin/site');
$this->template->content->title = Kohana::lang('ui_admin.settings');
// setup and initialize form field names
$form = array('site_name' => '', 'site_tagline' => '', 'site_email' => '', 'alerts_email' => '', 'site_language' => '', 'site_contact_page' => '', 'items_per_page' => '', 'items_per_page_admin' => '', 'allow_reports' => '', 'allow_comments' => '', 'allow_feed' => '', 'allow_stat_sharing' => '', 'allow_clustering' => '', 'default_map_all' => '', 'google_analytics' => '', 'twitter_hashtags' => '', 'api_akismet' => '');
// Copy the form as errors, so the errors will be stored with keys
// corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = FALSE;
// check, has the form been submitted, if so, setup validation
if ($_POST) {
// Instantiate Validation, use $post, so we don't overwrite $_POST
// fields with our own things
$post = new Validation($_POST);
// Add some filters
$post->pre_filter('trim', TRUE);
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('site_name', 'required', 'length[3,50]');
$post->add_rules('site_tagline', 'length[3,100]');
$post->add_rules('site_email', 'email', 'length[4,100]');
$post->add_rules('alerts_email', 'email', 'length[4,100]');
$post->add_rules('site_language', 'required', 'length[5, 5]');
//$post->add_rules('site_help_page','required','between[0,1]');
$post->add_rules('site_contact_page', 'required', 'between[0,1]');
$post->add_rules('items_per_page', 'required', 'between[10,50]');
$post->add_rules('items_per_page_admin', 'required', 'between[10,50]');
$post->add_rules('allow_reports', 'required', 'between[0,1]');
$post->add_rules('allow_comments', 'required', 'between[0,1]');
$post->add_rules('allow_feed', 'required', 'between[0,1]');
$post->add_rules('allow_stat_sharing', 'required', 'between[0,1]');
$post->add_rules('allow_clustering', 'required', 'between[0,1]');
$post->add_rules('default_map_all', 'required', 'alpha_numeric', 'length[6,6]');
$post->add_rules('google_analytics', 'length[0,20]');
$post->add_rules('twitter_hashtags', 'length[0,500]');
$post->add_rules('api_akismet', 'length[0,100]', 'alpha_numeric');
// Test to see if things passed the rule checks
if ($post->validate()) {
// Yes! everything is valid
$settings = new Settings_Model(1);
$settings->site_name = $post->site_name;
$settings->site_tagline = $post->site_tagline;
$settings->site_email = $post->site_email;
$settings->alerts_email = $post->alerts_email;
$settings->site_language = $post->site_language;
//$settings->site_help_page = $post->site_help_page;
$settings->site_contact_page = $post->site_contact_page;
$settings->items_per_page = $post->items_per_page;
$settings->items_per_page_admin = $post->items_per_page_admin;
$settings->allow_reports = $post->allow_reports;
$settings->allow_comments = $post->allow_comments;
$settings->allow_feed = $post->allow_feed;
$settings->allow_stat_sharing = $post->allow_stat_sharing;
$settings->allow_clustering = $post->allow_clustering;
$settings->default_map_all = $post->default_map_all;
$settings->google_analytics = $post->google_analytics;
$settings->twitter_hashtags = $post->twitter_hashtags;
$settings->api_akismet = $post->api_akismet;
$settings->date_modify = date("Y-m-d H:i:s", time());
$settings->save();
// Delete Settings Cache
$this->cache->delete('settings');
$this->cache->delete_tag('settings');
// Everything is A-Okay!
$form_saved = TRUE;
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
$errors = arr::overwrite($errors, $post->errors('settings'));
$form_error = TRUE;
}
} else {
// Retrieve Current Settings
$settings = ORM::factory('settings', 1);
$form = array('site_name' => $settings->site_name, 'site_tagline' => $settings->site_tagline, 'site_email' => $settings->site_email, 'alerts_email' => $settings->alerts_email, 'site_language' => $settings->site_language, 'site_contact_page' => $settings->site_contact_page, 'items_per_page' => $settings->items_per_page, 'items_per_page_admin' => $settings->items_per_page_admin, 'allow_reports' => $settings->allow_reports, 'allow_comments' => $settings->allow_comments, 'allow_feed' => $settings->allow_feed, 'allow_stat_sharing' => $settings->allow_stat_sharing, 'allow_clustering' => $settings->allow_clustering, 'default_map_all' => $settings->default_map_all, 'google_analytics' => $settings->google_analytics, 'twitter_hashtags' => $settings->twitter_hashtags, 'api_akismet' => $settings->api_akismet);
}
$this->template->colorpicker_enabled = TRUE;
$this->template->content->form = $form;
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->form_saved = $form_saved;
$this->template->content->items_per_page_array = array('10' => '10 Items', '20' => '20 Items', '30' => '30 Items', '50' => '50 Items');
$this->template->content->yesno_array = array('1' => strtoupper(Kohana::lang('ui_main.yes')), '0' => strtoupper(Kohana::lang('ui_main.no')));
// Generate Available Locales
$locales = locale::get_i18n();
$this->template->content->locales_array = $locales;
$this->cache->set('locales', $locales, array('locales'), 604800);
}
示例2: languages
public function languages()
{
// *** Locales/Languages ***
// First Get Available Locales
$locales = $this->cache->get('locales');
// If we didn't find any languages, we need to look them up and set the cache
if (!$locales) {
$locales = locale::get_i18n();
$this->cache->set('locales', $locales, array('locales'), 604800);
}
// Locale form submitted?
if (isset($_GET['l']) && !empty($_GET['l'])) {
$this->session->set('locale', $_GET['l']);
}
// Has a locale session been set?
if ($this->session->get('locale', FALSE)) {
// Change current locale
Kohana::config_set('locale.language', $_SESSION['locale']);
}
$languages = "";
$languages .= "<div class=\"language-box\">";
$languages .= "<form action=\"\">";
/**
* E.Kala - 05/01/2011
*
* Fix to ensure to ensure that a change in language loads the page with the same data
*
* Only fetch the $_GET data to prevent double submission of data already submitted via $_POST
* and create hidden form fields for each variable so that these are submitted along with the selected language
*
* The assumption is that previously submitted data had already been sanitized!
*/
foreach ($_GET as $name => $value) {
$languages .= form::hidden($name, $value);
}
// Do a case insensitive sort of locales so it comes up in a rough alphabetical order
natcasesort($locales);
$languages .= form::dropdown('l', $locales, Kohana::config('locale.language'), ' onchange="this.form.submit()" ');
$languages .= "</form>";
$languages .= "</div>";
return $languages;
}
示例3: index
function index()
{
$this->template->content = new View('admin/categories');
$this->template->content->title = Kohana::lang('ui_admin.categories');
// Locale (Language) Array
$locales = locale::get_i18n();
// Setup and initialize form field names
$form = array
(
'action' => '',
'category_id' => '',
'parent_id' => '',
'category_title' => '',
'category_description' => '',
'category_color' => '',
'category_image' => '',
'category_image_thumb' => ''
);
// Add the different language form keys for fields
foreach($locales as $lang_key => $lang_name){
$form['category_title_'.$lang_key] = '';
}
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = FALSE;
$form_action = "";
$parents_array = array();
// Check, has the form been submitted, if so, setup validation
if ($_POST)
{
// Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
$post = Validation::factory(array_merge($_POST,$_FILES));
// Add some filters
$post->pre_filter('trim', TRUE);
// Add Action
if ($post->action == 'a')
{
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('parent_id','required','numeric');
$post->add_rules('category_title','required', 'length[3,80]');
$post->add_rules('category_description','required');
$post->add_rules('category_color','required', 'length[6,6]');
$post->add_rules('category_image', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[50K]');
$post->add_callbacks('parent_id', array($this,'parent_id_chk'));
// Add the different language form keys for fields
foreach($locales as $lang_key => $lang_name){
$post->add_rules('category_title_lang['.$lang_key.']','length[3,80]');
}
}
// Test to see if things passed the rule checks
if ($post->validate())
{
$category_id = $post->category_id;
$category = new Category_Model($category_id);
// Grab languages if they already exist
$category_lang = Category_Lang_Model::category_langs($category->id);
if(isset($category_lang[$category->id]))
{
$category_lang = $category_lang[$category->id];
}else{
$category_lang = FALSE;
}
if( $post->action == 'd' )
{ // Delete Action
// Delete localizations
ORM::factory('category_lang')
->where(array('category_id' => $category_id))
->delete_all();
// Delete category itself
ORM::factory('category')
->where('category_trusted != 1')
->delete($category_id);
$form_saved = TRUE;
$form_action = strtoupper(Kohana::lang('ui_admin.deleted'));
}
elseif( $post->action == 'v' )
{ // Show/Hide Action
//.........这里部分代码省略.........
示例4: languages
public function languages()
{
// *** Locales/Languages ***
// First Get Available Locales
$locales = $this->cache->get('locales');
// If we didn't find any languages, we need to look them up and set the cache
if (!$locales) {
$locales = locale::get_i18n();
$this->cache->set('locales', $locales, array('locales'), 604800);
}
// Locale form submitted?
if (isset($_GET['l']) && !empty($_GET['l'])) {
$this->session->set('locale', $_GET['l']);
}
// Has a locale session been set?
if ($this->session->get('locale', FALSE)) {
// Change current locale
Kohana::config_set('locale.language', $_SESSION['locale']);
}
$languages = "";
$languages .= "<div class=\"language-box\">";
$languages .= "<form action=\"\">";
$languages .= form::dropdown('l', $locales, Kohana::config('locale.language'), ' onchange="this.form.submit()" ');
$languages .= "</form>";
$languages .= "</div>";
return $languages;
}
示例5: index
/**
* Add Edit Categories
*/
public function index()
{
$this->template->content = new View('admin/categories');
$this->template->content->title = Kohana::lang('ui_admin.categories');
// Locale (Language) Array
$locales = locale::get_i18n();
// Setup and initialize form field names
$form = array('action' => '', 'category_id' => '', 'parent_id' => '', 'category_title' => '', 'category_description' => '', 'category_color' => '', 'category_image' => '', 'category_image_thumb' => '');
// Add the different language form keys for fields
foreach ($locales as $lang_key => $lang_name) {
$form['category_title_' . $lang_key] = '';
}
// Copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$errors = $form;
$form_error = FALSE;
$form_saved = FALSE;
$form_action = "";
$parents_array = array();
// Check, has the form been submitted, if so, setup validation
if ($_POST) {
// Fetch the post data
$post_data = array_merge($_POST, $_FILES);
// Extract category-specific information
$category_data = arr::extract($post_data, 'parent_id', 'category_title', 'category_description', 'category_color');
// Extract category image and category languages for independent validation
$secondary_data = arr::extract($post_data, 'category_image', 'category_title_lang', 'action');
// Setup validation for the secondary data
$post = Validation::factory($secondary_data)->pre_filter('trim', TRUE);
// Add validation for the add/edit action
if ($post->action == 'a') {
$post->add_rules('category_image', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[50K]');
// Add the different language form keys for fields
foreach ($locales as $lang_key => $lang_name) {
$post->add_rules('category_title_lang[' . $lang_key . ']', 'length[3,80]');
}
}
// Category instance for the operation
$category = (!empty($_POST['category_id']) and Category_Model::is_valid_category($_POST['category_id'])) ? new Category_Model($_POST['category_id']) : new Category_Model();
// Check the specified action
if ($post->action == 'a') {
// Test to see if things passed the rule checks
if ($category->validate($category_data) and $post->validate()) {
// Save the category
$category->save();
// Get the category localization
$languages = $category->loaded ? Category_Lang_Model::category_langs($category->id) : FALSE;
$category_lang = isset($languages[$category->id]) ? $languages[$category->id] : FALSE;
// Save localizations
foreach ($post->category_title_lang as $lang_key => $localized_category_name) {
$cl = isset($category_lang[$lang_key]['id']) ? ORM::factory('category_lang', $category_lang[$lang_key]['id']) : ORM::factory('category_lang');
$cl->category_title = $localized_category_name;
$cl->locale = $lang_key;
$cl->category_id = $category->id;
$cl->save();
}
// Upload Image/Icon
$filename = upload::save('category_image');
if ($filename) {
$new_filename = "category_" . $category->id . "_" . time();
// Resize Image to 32px if greater
Image::factory($filename)->resize(32, 32, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $new_filename . ".png");
// Create a 16x16 version too
Image::factory($filename)->resize(16, 16, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $new_filename . "_16x16.png");
// Remove the temporary file
unlink($filename);
// Delete Old Image
$category_old_image = $category->category_image;
if (!empty($category_old_image) and file_exists(Kohana::config('upload.directory', TRUE) . $category_old_image)) {
unlink(Kohana::config('upload.directory', TRUE) . $category_old_image);
}
// Save
$category->category_image = $new_filename . ".png";
$category->category_image_thumb = $new_filename . "_16x16.png";
$category->save();
}
$form_saved = TRUE;
$form_action = strtoupper(Kohana::lang('ui_admin.added_edited'));
// Empty $form array
array_fill_keys($form, '');
} else {
// Validation failed
// Repopulate the form fields
$form = arr::overwrite($form, array_merge($category_data->as_array(), $post->as_array()));
// populate the error fields, if any
$errors = arr::overwrite($errors, array_merge($category_data->errors('category'), $post->errors('category')));
$form_error = TRUE;
}
} elseif ($post->action == 'd') {
// Delete action
if ($category->loaded) {
ORM::factory('category_lang')->where(array('category_id' => $category->id))->delete_all();
// @todo Delete the category image
// Delete category itself - except if it is trusted
ORM::factory('category')->where('category_trusted != 1')->delete($category->id);
$form_saved = TRUE;
$form_action = strtoupper(Kohana::lang('ui_admin.deleted'));
}
//.........这里部分代码省略.........
示例6: site
//.........这里部分代码省略.........
// Delete old badge image
ORM::factory('media')->delete($settings->site_banner_id);
// Remove from DB table
$settings = new Settings_Model(1);
$settings->site_banner_id = NULL;
$settings->save();
} else {
// We aren't deleting, so try to upload if we are uploading an image
$filename = upload::save('banner_image');
if ($filename) {
$new_filename = "banner";
$file_type = strrev(substr(strrev($filename), 0, 4));
// Large size
$l_name = $new_filename . $file_type;
Image::factory($filename)->save(Kohana::config('upload.directory', TRUE) . $l_name);
// Medium size
$m_name = $new_filename . "_m" . $file_type;
Image::factory($filename)->resize(80, 80, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $m_name);
// Thumbnail
$t_name = $new_filename . "_t" . $file_type;
Image::factory($filename)->resize(60, 60, Image::HEIGHT)->save(Kohana::config('upload.directory', TRUE) . $t_name);
// Remove the temporary file
unlink($filename);
// Save banner image in the media table
$media = new Media_Model();
$media->media_type = 1;
// Image
$media->media_link = $l_name;
$media->media_medium = $m_name;
$media->media_thumb = $t_name;
$media->media_date = date("Y-m-d H:i:s", time());
$media->save();
// Save new banner image in settings
$settings = new Settings_Model(1);
$settings->site_banner_id = $media->id;
$settings->save();
}
}
// Delete Settings Cache
$this->cache->delete('settings');
$this->cache->delete_tag('settings');
// Everything is A-Okay!
$form_saved = TRUE;
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
} else {
// repopulate the form fields
$form = arr::overwrite($form, $post->as_array());
// populate the error fields, if any
if (is_array($files->errors()) and count($files->errors()) > 0) {
// Error with file upload
$errors = arr::overwrite($errors, $files->errors('settings'));
} else {
// Error with other form filed
$errors = arr::overwrite($errors, $post->errors('settings'));
}
$form_error = TRUE;
}
} else {
// Retrieve Current Settings
$settings = ORM::factory('settings', 1);
$form = array('site_name' => $settings->site_name, 'site_tagline' => $settings->site_tagline, 'site_banner_id' => $settings->site_banner_id, 'site_email' => $settings->site_email, 'alerts_email' => $settings->alerts_email, 'site_message' => $settings->site_message, 'site_copyright_statement' => $settings->site_copyright_statement, 'site_submit_report_message' => $settings->site_submit_report_message, 'site_language' => $settings->site_language, 'site_timezone' => $settings->site_timezone, 'site_contact_page' => $settings->site_contact_page, 'items_per_page' => $settings->items_per_page, 'items_per_page_admin' => $settings->items_per_page_admin, 'blocks_per_row' => $settings->blocks_per_row, 'allow_reports' => $settings->allow_reports, 'allow_comments' => $settings->allow_comments, 'allow_feed' => $settings->allow_feed, 'allow_stat_sharing' => $settings->allow_stat_sharing, 'allow_clustering' => $settings->allow_clustering, 'cache_pages' => $settings->cache_pages, 'cache_pages_lifetime' => $settings->cache_pages_lifetime, 'private_deployment' => $settings->private_deployment, 'checkins' => $settings->checkins, 'default_map_all' => $settings->default_map_all, 'google_analytics' => $settings->google_analytics, 'twitter_hashtags' => $settings->twitter_hashtags, 'api_akismet' => $settings->api_akismet);
}
// Get banner image
if ($settings->site_banner_id != NULL) {
$banner = ORM::factory('media')->find($settings->site_banner_id);
$this->template->content->banner = $banner->media_link;
$this->template->content->banner_m = $banner->media_medium;
$this->template->content->banner_t = $banner->media_thumb;
} else {
$this->template->content->banner = NULL;
$this->template->content->banner_m = NULL;
$this->template->content->banner_t = NULL;
}
$this->template->colorpicker_enabled = TRUE;
$this->template->content->form = $form;
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->form_saved = $form_saved;
$this->template->content->items_per_page_array = array('10' => '10 Items', '20' => '20 Items', '30' => '30 Items', '50' => '50 Items');
$blocks_per_row_array = array();
for ($i = 1; $i <= 21; $i++) {
$blocks_per_row_array[$i] = $i;
}
$this->template->content->blocks_per_row_array = $blocks_per_row_array;
$this->template->content->yesno_array = array('1' => strtoupper(Kohana::lang('ui_main.yes')), '0' => strtoupper(Kohana::lang('ui_main.no')));
$this->template->content->comments_array = array('1' => strtoupper(Kohana::lang('ui_main.yes') . " - " . Kohana::lang('ui_admin.approve_auto')), '2' => strtoupper(Kohana::lang('ui_main.yes') . " - " . Kohana::lang('ui_admin.approve_manual')), '0' => strtoupper(Kohana::lang('ui_main.no')));
$this->template->content->cache_pages_lifetime_array = array('300' => '5 ' . Kohana::lang('ui_admin.minutes'), '600' => '10 ' . Kohana::lang('ui_admin.minutes'), '900' => '15 ' . Kohana::lang('ui_admin.minutes'), '1800' => '30 ' . Kohana::lang('ui_admin.minutes'));
//Generate all timezones
$site_timezone_array = array();
$site_timezone_array[0] = Kohana::lang('ui_admin.server_time');
foreach (timezone_identifiers_list() as $timezone) {
$site_timezone_array[$timezone] = $timezone;
}
$this->template->content->site_timezone_array = $site_timezone_array;
// Generate Available Locales
$locales = locale::get_i18n();
$this->template->content->locales_array = $locales;
$this->cache->set('locales', $locales, array('locales'), 604800);
}
示例7: _report_view
/**
* Render the Action Taken Information to the Report
* on the front end
*/
public function _report_view()
{
// Load the View
$view = View::factory('translatereports_frontend');
// Get ID of the incident we either added or are modifying
$incident_id = Event::$data;
// Grab Existing Translations
$translation_items = ORM::factory('translatereports')->where('incident_id', $incident_id)->find_all();
$translations = array();
foreach ($translation_items as $item) {
$translations[$item->lang] = $item->incident_description;
}
$view->translations = $translations;
if (Kohana::config('translatereports.languages') == NULL) {
if (count($this->cache->get('locales')) > 0) {
$view->locales = $this->cache->get('locales');
} else {
$view->locales = locale::get_i18n();
}
} else {
$view->locales = Kohana::config('translatereports.languages');
}
$view->render(TRUE);
}
示例8: __construct
public function __construct()
{
parent::__construct();
// Load cache
$this->cache = new Cache();
// Load Session
$this->session = Session::instance();
// Load Header & Footer
$this->template->header = new View('header');
$this->template->footer = new View('footer');
// In case js doesn't get set in the construct, initialize it here
$this->template->header->js = '';
// Set Table Prefix
$this->table_prefix = Kohana::config('database.default.table_prefix');
// Retrieve Default Settings
$site_name = Kohana::config('settings.site_name');
// Prevent Site Name From Breaking up if its too long
// by reducing the size of the font
if (strlen($site_name) > 20) {
$site_name_style = " style=\"font-size:21px;\"";
} else {
$site_name_style = "";
}
$this->template->header->site_name = $site_name;
$this->template->header->site_name_style = $site_name_style;
$this->template->header->site_tagline = Kohana::config('settings.site_tagline');
$this->template->header->api_url = Kohana::config('settings.api_url');
// Display Contact Tab?
$this->template->header->site_contact_page = Kohana::config('settings.site_contact_page');
// Display Help Tab?
$this->template->header->site_help_page = Kohana::config('settings.site_help_page');
// Get Custom Pages
$this->template->header->pages = ORM::factory('page')->where('page_active', '1')->find_all();
// Get custom CSS file from settings
$this->template->header->site_style = Kohana::config('settings.site_style');
// Javascript Header
$this->template->header->map_enabled = FALSE;
$this->template->header->validator_enabled = TRUE;
$this->template->header->treeview_enabled = FALSE;
$this->template->header->datepicker_enabled = FALSE;
$this->template->header->photoslider_enabled = FALSE;
$this->template->header->videoslider_enabled = FALSE;
$this->template->header->protochart_enabled = FALSE;
$this->template->header->main_page = FALSE;
$this->template->header->this_page = "";
// Google Analytics
$google_analytics = Kohana::config('settings.google_analytics');
$this->template->footer->google_analytics = $this->_google_analytics($google_analytics);
// *** Locales/Languages ***
// First Get Available Locales
$locales = $this->cache->get('locales');
// If we didn't find any languages, we need to look them up and set the cache
if (!$locales) {
$locales = locale::get_i18n();
$this->cache->set('locales', $locales, array('locales'), 604800);
}
$this->template->header->locales_array = $locales;
// Locale form submitted?
if (isset($_GET['l']) && !empty($_GET['l'])) {
$this->session->set('locale', $_GET['l']);
}
// Has a locale session been set?
if ($this->session->get('locale', FALSE)) {
// Change current locale
Kohana::config_set('locale.language', $_SESSION['locale']);
}
$this->template->header->l = Kohana::config('locale.language');
// Load profiler
// $profiler = new Profiler;
// Get tracking javascript for stats
$this->template->footer->ushahidi_stats = Stats_Model::get_javascript();
}