当前位置: 首页>>代码示例>>PHP>>正文


PHP i18n::get_languages方法代码示例

本文整理汇总了PHP中i18n::get_languages方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::get_languages方法的具体用法?PHP i18n::get_languages怎么用?PHP i18n::get_languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在i18n的用法示例。


在下文中一共展示了i18n::get_languages方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_edit

 /**
  * action: EDIT
  */
 public function action_edit()
 {
     $id = $this->request->param('id');
     $content = new Model_Content($id);
     $type = $content->type;
     $site = $type == 'page' ? __('Page') : __('Email');
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $site));
     $locale = $content->locale;
     if ($content->loaded()) {
         $languages = i18n::get_languages();
         $this->template->content = View::factory('oc-panel/pages/content/edit', array('cont' => $content, 'locale' => $languages));
         if ($p = $this->request->post()) {
             foreach ($p as $name => $value) {
                 if ($name != 'submit') {
                     $content->{$name} = $value;
                 }
             }
             // if status is not checked, it is not set as POST response
             $content->status = isset($p['status']) ? 1 : 0;
             //$content->seotitle = $content->gen_seotitle($this->request->post('title'));
             try {
                 $content->save();
                 Cache::instance()->delete_all();
                 Alert::set(Alert::SUCCESS, $content->type . ' ' . __('is edited'));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit', 'id' => $content->id_content)));
             } catch (Exception $e) {
                 Alert::set(Alert::ERROR, $e->getMessage());
             }
         }
     } else {
         Alert::set(Alert::INFO, __('Faild to load content'));
         Request::current()->redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit')) . '?type=' . $type . '&locale_select=' . $locale);
     }
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:37,代码来源:content.php

示例2: action_index

 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     $parse = $this->request->query('parse');
     if ($parse) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if ($this->request->param('id')) {
         //save language
         $locale = new Model_Config();
         $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find();
         if (!$locale->loaded()) {
             $locale->group_name = 'i18n';
             $locale->config_key = 'locale';
         }
         $locale->config_value = $this->request->param('id');
         try {
             $locale->save();
             Alert::set(Alert::SUCCESS, __('Translations regenarated'));
         } catch (Exception $e) {
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
     }
     //create language
     if (Core::post('locale')) {
         $language = $this->request->post('locale');
         $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/';
         // if folder does not exist, try to make it
         if (!file_exists($folder) and !@mkdir($folder, 0775, true)) {
             // mkdir not successful ?
             Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
         }
         // write an empty .po file for $language
         $out = 'msgid ""' . PHP_EOL;
         $out .= 'msgstr ""' . PHP_EOL;
         File::write($folder . 'messages.po', $out);
         Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved'));
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
开发者ID:demoic,项目名称:common,代码行数:55,代码来源:translations.php

示例3: before

 /**
  * Automatically executed before the widget action. Can be used to set
  * class properties, do authorization checks, and execute other custom code.
  *
  * @return  void
  */
 public function before()
 {
     //we need this option enabled for this plugin to work
     if (Core::config('i18n.allow_query_language') == 0) {
         Model_Config::set_value('i18n', 'allow_query_language', 1);
     }
     if ($this->languages == '') {
         $this->languages = i18n::get_languages();
     } else {
         $this->languages = array_map('trim', explode(',', $this->languages));
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:18,代码来源:languages.php

示例4: action_index

 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     if (core::get('parse') !== NULL) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if (($locale = $this->request->param('id')) != NULL and array_key_exists($locale, i18n::get_languages())) {
         //save language
         Model_Config::set_value('i18n', 'locale', $locale);
         //change the cookie if not he will not see the changes
         if (Core::config('i18n.allow_query_language') == 1) {
             Cookie::set('user_language', $locale, Core::config('auth.lifetime'));
         }
         Alert::set(Alert::SUCCESS, __('Language') . ' ' . $locale);
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
     }
     //create language
     if (Core::post('locale')) {
         $language = $this->request->post('locale');
         $folder = DOCROOT . 'languages/' . $language . '/LC_MESSAGES/';
         // if folder does not exist, try to make it
         if (!file_exists($folder) and !@mkdir($folder, 0775, true)) {
             // mkdir not successful ?
             Alert::set(Alert::ERROR, __('Language folder cannot be created with mkdir. Please correct to be able to create new translation.'));
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'translations')));
         }
         // write an empty .po file for $language
         $out = 'msgid ""' . PHP_EOL;
         $out .= 'msgstr ""' . PHP_EOL;
         File::write($folder . 'messages.po', $out);
         Alert::set(Alert::SUCCESS, $this->request->param('id') . ' ' . __('Language saved'));
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
开发者ID:ThomWensink,项目名称:common,代码行数:47,代码来源:translations.php

示例5: action_index

 public function action_index()
 {
     // validation active
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('List')));
     $this->template->title = __('Translations');
     //scan project files and generate .po
     $parse = $this->request->query('parse');
     if ($parse) {
         //scan script
         require_once Kohana::find_file('vendor', 'POTCreator/POTCreator', 'php');
         $obj = new POTCreator();
         $obj->set_root(DOCROOT);
         $obj->set_exts('php');
         $obj->set_regular('/_[_|e]\\([\\"|\']([^\\"|\']+)[\\"|\']\\)/i');
         $obj->set_base_path('..');
         $obj->set_read_subdir(true);
         $obj->write_pot(i18n::get_language_path());
         Alert::set(Alert::SUCCESS, 'File regenerated');
     }
     //change default site language
     if ($this->request->param('id')) {
         //save language
         $locale = new Model_Config();
         $locale->where('group_name', '=', 'i18n')->where('config_key', '=', 'locale')->limit(1)->find();
         if (!$locale->loaded()) {
             $locale->group_name = 'i18n';
             $locale->config_key = 'locale';
         }
         $locale->config_value = $this->request->param('id');
         try {
             $locale->save();
             Alert::set(Alert::SUCCESS, '');
             Request::current()->redirect(Route::url('oc-panel', array('controller' => 'translations')));
         } catch (Exception $e) {
             echo $e;
         }
     }
     $this->template->content = View::factory('oc-panel/pages/translations/index', array('languages' => i18n::get_languages(), 'current_language' => core::config('i18n.locale')));
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:39,代码来源:translations.php

示例6: action_edit

 /**
  * action: EDIT
  */
 public function action_edit()
 {
     $id = $this->request->param('id');
     $content = new Model_Content($id);
     $type = $content->type;
     $site = self::translate_type($type);
     Breadcrumbs::add(Breadcrumb::factory()->set_title($site)->set_url(Route::url('oc-panel', array('controller' => 'content', 'action' => $type))));
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $site));
     $locale = $content->locale;
     if ($content->loaded()) {
         $languages = i18n::get_languages();
         $this->template->content = View::factory('oc-panel/pages/content/edit', array('cont' => $content, 'locale' => $languages));
         if ($p = $this->request->post()) {
             foreach ($p as $name => $value) {
                 //for description we accept the HTML as comes...a bit risky but only admin can
                 if ($name == 'description') {
                     $content->description = Kohana::$_POST_ORIG['description'];
                 } elseif ($name != 'submit') {
                     $content->{$name} = $value;
                 }
             }
             // if status is not checked, it is not set as POST response
             $content->status = isset($p['status']) ? 1 : 0;
             try {
                 $content->save();
                 Alert::set(Alert::SUCCESS, $content->type . ' ' . __('is edited'));
             } catch (Exception $e) {
                 Alert::set(Alert::ERROR, $e->getMessage());
             }
             HTTP::redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit', 'id' => $content->id_content)));
         }
     } else {
         Alert::set(Alert::INFO, __('Failed to load content'));
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit')) . '?type=' . $type . '&locale_select=' . $locale);
     }
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:39,代码来源:content.php

示例7: form_setup

 public function form_setup($form)
 {
     $form->fields['order']['display_as'] = 'select';
     $form->fields['order']['options'] = range(0, 30);
     $form->fields['locale']['display_as'] = 'select';
     $form->fields['locale']['options'] = i18n::get_languages();
     $form->fields['seotitle']['display_as'] = 'hidden';
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:8,代码来源:content.php

示例8: foreach

 /**
  * get language codes as options of a selectable list
  *
  * This function returns a full <select> tag with the name 'language' and the id 'language'.
  *
  * If no parameter is provided, then surfer language is used.
  *
  * @param string the current language, if any
  * @param string alternate name and id of the returned tag
  * @return the HTML to insert in the page
  */
 public static function &get_languages_select($current = NULL, $id = 'language')
 {
     global $context;
     // use surfer language by default
     if (!$current) {
         $current = $context['language'];
     }
     // all options
     $text = '<select name="' . $id . '" id="' . $id . '">' . "\n";
     // fetch the list of languages
     $languages =& i18n::get_languages();
     // engage surfer
     $text .= '<option value="none">' . i18n::s('Use browser settings') . "</option>\n";
     // current language setting
     if ($current == $context['language']) {
         $text .= '<option value="' . $context['language'] . '" selected="selected">' . i18n::get_language_label($context['language']) . "</option>\n";
     } else {
         $text .= '<option value="' . $context['language'] . '">' . i18n::get_language_label($context['language']) . "</option>\n";
     }
     // all options
     foreach ($languages as $code => $label) {
         // is this the current setting?
         if ($code == $context['language']) {
             continue;
         }
         // the code
         $text .= '<option value="' . $code . '"';
         // is this the current option?
         if ($code == $current) {
             $text .= ' selected="selected"';
         }
         // the label for this language
         $text .= '>' . $label . "</option>\n";
     }
     // return by reference
     $text .= '</select>';
     // job done
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:50,代码来源:i18n.php


注:本文中的i18n::get_languages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。