echo framework_include_css(); } // set the language so local module languages take $language = set_language(); // send menu $menu['fpbx_menu'] = $fpbx_menu; //array of modules & settings $menu['display'] = $display; //currently displayed item $menu['authtype'] = $amp_conf['AUTHTYPE']; $menu['reload_confirm'] = $amp_conf['RELOADCONFIRM']; $menu['language'] = array('en_US' => _('English') . " (US)"); $langKey = !empty($_COOKIE['lang']) ? $_COOKIE['lang'] : 'en_US'; foreach (glob($amp_conf['AMPWEBROOT'] . "/admin/i18n/*", GLOB_ONLYDIR) as $langDir) { $lang = basename($langDir); $menu['language'][$lang] = function_exists('locale_get_display_name') ? locale_get_display_name($lang, $langKey) : $lang; } //add menu to final output echo load_view($amp_conf['VIEW_MENU'], $menu); // provide beta status if (isset($fpbx_menu[$display]['beta']) && strtolower($fpbx_menu[$display]['beta']) == 'yes') { echo load_view($amp_conf['VIEW_BETA_NOTICE']); } //send actual page content echo $page_content; //send footer $footer['lang'] = $language; $footer['covert'] = in_array($display, array('noauth', 'badrefer')) ? true : false; $footer['extmap'] = !$footer['covert'] ? framework_get_extmap(true) : json_encode(array()); $footer['module_name'] = $module_name; $footer['module_page'] = $module_page;
public function index() { \CI::load()->helper('form'); \CI::load()->library('form_validation'); //set defaults $data = ['company_name' => '', 'theme' => 'default', 'homepage' => '', 'products_per_page' => '24', 'default_meta_keywords' => '', 'default_meta_description' => '', 'sendmail_path' => '/usr/sbin/sendmail -bs', 'email_from' => '', 'email_to' => '', 'email_method' => 'Mail', 'smtp_server' => '', 'smtp_username' => '', 'smtp_password' => '', 'smtp_port' => '25', 'country_id' => '', 'city' => '', 'address1' => '', 'address2' => '', 'zone_id' => '', 'zip' => '', 'locale' => locale_get_default(), 'timezone' => date_default_timezone_get(), 'currency_iso' => 'USD', 'ssl_support' => '', 'stage_username' => '', 'stage_password' => '', 'require_login' => '', 'new_customer_status' => '1', 'weight_unit' => 'LB', 'dimension_unit' => 'IN', 'order_status' => '', 'inventory_enabled' => '', 'allow_os_purchase' => '', 'tax_address' => '', 'tax_shipping' => '']; \CI::form_validation()->set_rules('company_name', 'lang:company_name', 'required'); \CI::form_validation()->set_rules('default_meta_keywords', 'lang:default_meta_keywords', 'trim|strip_tags'); \CI::form_validation()->set_rules('default_meta_description', 'lang:default_meta_description', 'trim|strip_tags'); \CI::form_validation()->set_rules('theme', 'lang:theme', 'required'); \CI::form_validation()->set_rules('homepage', 'lang:select_homepage'); \CI::form_validation()->set_rules('products_per_page', 'lang:products_per_page'); \CI::form_validation()->set_rules('email_from', 'lang:email_from', 'required|valid_email'); \CI::form_validation()->set_rules('email_to', 'lang:email_to', 'required|valid_email'); \CI::form_validation()->set_rules('email_method', 'lang:email_method', 'required'); if (\CI::input()->post('email_method') == 'smtp') { \CI::form_validation()->set_rules('smtp_server', 'lang:smtp_server', 'required'); \CI::form_validation()->set_rules('smtp_username', 'lang:smtp_username', 'required'); \CI::form_validation()->set_rules('smtp_password', 'lang:smtp_password', 'required'); \CI::form_validation()->set_rules('smtp_port', 'lang:smtp_port', 'required'); } elseif (\CI::input()->post('email_method') == 'sendmail') { \CI::form_validation()->set_rules('sendmail_path', 'lang:sendmail_path', 'required'); } \CI::form_validation()->set_rules('country_id', 'lang:country'); \CI::form_validation()->set_rules('address1', 'lang:address'); \CI::form_validation()->set_rules('address2', 'lang:address'); \CI::form_validation()->set_rules('zone_id', 'lang:state'); \CI::form_validation()->set_rules('zip', 'lang:zip'); \CI::form_validation()->set_rules('locale', 'lang:locale', 'required'); \CI::form_validation()->set_rules('timezone', 'lang:timezone', 'required'); \CI::form_validation()->set_rules('currency_iso', 'lang:currency', 'required'); \CI::form_validation()->set_rules('ssl_support', 'lang:ssl_support'); \CI::form_validation()->set_rules('stage', 'lang:stage'); \CI::form_validation()->set_rules('stage_username', 'lang:stage_username'); \CI::form_validation()->set_rules('stage_password', 'lang:stage_password'); \CI::form_validation()->set_rules('require_login', 'lang:require_login'); \CI::form_validation()->set_rules('new_customer_status', 'lang:new_customer_status'); \CI::form_validation()->set_rules('weight_unit', 'lang:weight_unit'); \CI::form_validation()->set_rules('order_status', 'lang:order_status'); \CI::form_validation()->set_rules('inventory_enabled', 'lang:inventory_enabled'); \CI::form_validation()->set_rules('allow_os_purchase', 'lang:allow_os_purchase'); \CI::form_validation()->set_rules('tax_address', 'lang:tax_address'); \CI::form_validation()->set_rules('tax_shipping', 'lang:tax_shipping'); // get the values from the DB $data = array_merge($data, \CI::Settings()->get_settings('gocart')); $data['config'] = $data; //break out order statuses to an array //get installed themes $data['themes'] = []; $themePath = FCPATH . 'themes/'; if ($handle = opendir($themePath)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && is_dir($themePath . $entry)) { $data['themes'][$entry] = $entry; } } closedir($handle); } asort($data['themes']); //get locales $locales = \ResourceBundle::getLocales(''); $data['locales'] = []; foreach ($locales as $locale) { $data['locales'][$locale] = locale_get_display_name($locale); } asort($data['locales']); //get ISO 4217 codes $data['iso_4217'] = []; $iso_4217 = json_decode(json_encode(simplexml_load_file(FCPATH . 'ISO_4217.xml'))); $iso_4217 = $iso_4217->CcyTbl->CcyNtry; foreach ($iso_4217 as $iso_code) { if (isset($iso_code->Ccy)) { $data['iso_4217'][$iso_code->Ccy] = $iso_code->Ccy; } } asort($data['iso_4217']); $data['countries_menu'] = \CI::Locations()->get_countries_menu(); if (!empty($data['country_id'])) { $data['zones_menu'] = \CI::Locations()->get_zones_menu($data['country_id']); } else { $countries_menu = array_keys($data['countries_menu']); $data['zones_menu'] = \CI::Locations()->get_zones_menu(array_shift($countries_menu)); } $data['page_title'] = lang('common_gocart_configuration'); $pages = \CI::Pages()->get_pages_tiered(); $data['pages'] = []; foreach ($pages['all'] as $page) { if (empty($page->url)) { $data['pages'][$page->id] = $page->title; } } if (\CI::form_validation()->run() == FALSE) { $data['error'] = validation_errors(); $this->view('settings', $data); } else { \CI::session()->set_flashdata('message', lang('config_updated_message')); $save = \CI::input()->post(); //fix boolean values $save['ssl_support'] = (bool) \CI::input()->post('ssl_support'); $save['require_login'] = (bool) \CI::input()->post('require_login'); $save['new_customer_status'] = \CI::input()->post('new_customer_status'); $save['allow_os_purchase'] = (bool) \CI::input()->post('allow_os_purchase'); $save['tax_shipping'] = (bool) \CI::input()->post('tax_shipping'); $save['homepage'] = \CI::input()->post('homepage'); \CI::Settings()->save_settings('gocart', $save); redirect('admin/settings'); } }
/** * Get Languages * * This gets unique languges: * OUT > Array * ( * [en] => English * [en_GB] => English (United Kingdom) * ) * @return [type] [description] */ public function getLanguages() { $names = $this->getLanguageNames(); $locations = $this->getLocationNames(); $packagelangs = array(); $packages = $this->getPackages(); if (!empty($packages)) { foreach ($packages as $package) { if (!empty($package['installed'])) { //Try to use local_get_display_name if it's installed if (function_exists('locale_get_display_name')) { $language = set_language(); $name = locale_get_display_name($package['language'], $language); } else { $lang = explode('_', $package['language'], 2); if (count($lang) == 2 && !empty($locations[$lang[1]]) && !empty($names[$lang[0]])) { $name = $names[$lang[0]] . ' - ' . $locations[$lang[1]]; } else { if (!empty($names[$lang[0]])) { $name = $names[$lang[0]]; } else { $name = $lang[0]; } } } $packagelangs[$package['language']] = $name; } } } $customlangs = array(); $customs = $this->getCustomLanguages(); if (!empty($customs)) { foreach ($customs as $customlang) { $customlangs[$customlang['language']] = $customlang['description']; } } $languages = array_merge($packagelangs, $customlangs); if (empty($languages)) { $languages = array('en' => $names['en']); } asort($languages); return $languages; }
$module = ''; if (!empty($_REQUEST['display']) || !empty($_REQUEST['mod']) || isset($_REQUEST['logout'])) { //TODO: logout code? } } switch ($display) { case "settings": case "dashboard": if ($display == "settings") { $ucp->Modgettext->push_textdomain("ucp"); $displayvars['desktop'] = !$ucp->Session->isMobile && !$ucp->Session->isTablet; $displayvars['lang'] = $lang; $displayvars['languages'] = array('en_US' => _('English') . " (US)"); foreach (glob(FreePBX::Config()->get('AMPWEBROOT') . "/admin/modules/ucp/i18n/*", GLOB_ONLYDIR) as $langDir) { $l = basename($langDir); $displayvars['languages'][$l] = function_exists('locale_get_display_name') ? locale_get_display_name($l, $lang) : $l; } $displayvars['changepassword'] = $ucp->User->canChange("password"); $displayvars['changeusername'] = $ucp->User->canChange("username"); $displayvars['changedetails'] = $ucp->User->canChange("details"); $displayvars['username'] = $user['username']; $dashboard_content = $ucp->View->load_view(__DIR__ . '/views/settings.php', $displayvars); $displayvars['active_module'] = 'ucpsettings'; $ucp->Modgettext->pop_textdomain(); } else { if ($module != "home") { $ucp->Modgettext->push_textdomain(strtolower($module)); } else { $ucp->Modgettext->push_textdomain("ucp"); } $displayvars['active_module'] = $module;
/** * List of all locales. * * @param string $locale * @access public * @return array * @static * * @author Etienne de Longeaux <*****@*****.**> */ public static function allLocales($locale) { $localelist = \Zend_Locale::getLocaleList(); $name_key = array_map(function ($key, $locale) { return locale_get_display_name(strtolower($key), strtolower($locale)) . " - ({$key})"; }, array_keys($localelist), array_fill(0, count($localelist) - 1, $locale)); return array_combine(array_keys($localelist), $name_key); }
function test($len) { return locale_get_display_name(str_repeat('*', $len), 'a'); }
function index() { $this->load->helper('form'); $this->load->library('form_validation'); $this->form_validation->set_rules('company_name', 'lang:company_name', 'required'); $this->form_validation->set_rules('theme', 'lang:theme', 'required'); $this->form_validation->set_rules('email', 'lang:cart_email', 'required|valid_email'); $this->form_validation->set_rules('country_id', 'lang:country'); $this->form_validation->set_rules('address1', 'lang:address'); $this->form_validation->set_rules('address2', 'lang:address'); $this->form_validation->set_rules('zone_id', 'lang:state'); $this->form_validation->set_rules('zip', 'lang:zip'); $this->form_validation->set_rules('locale', 'lang:locale', 'required'); $this->form_validation->set_rules('currency_iso', 'lang:currency', 'required'); $data = $this->Settings_model->get_settings('jcart'); $data['config'] = $data; //break out order statuses to an array //get installed themes $data['themes'] = array(); if ($handle = opendir(FCPATH . APPPATH . '/themes')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && is_dir(FCPATH . APPPATH . '/themes/' . $entry)) { $data['themes'][$entry] = $entry; } } closedir($handle); } asort($data['themes']); //get locales //$locales = ResourceBundle::getLocales(''); $locales = $data['locales'] = array(); foreach ($locales as $locale) { $data['locales'][$locale] = locale_get_display_name($locale); } asort($data['locales']); //get ISO 4217 codes $data['iso_4217'] = array(); $iso_4217 = json_decode(json_encode(simplexml_load_file(FCPATH . 'ISO_4217.xml'))); $iso_4217 = $iso_4217->CcyTbl->CcyNtry; foreach ($iso_4217 as $iso_code) { if (isset($iso_code->Ccy)) { $data['iso_4217'][$iso_code->Ccy] = $iso_code->Ccy; } } asort($data['iso_4217']); $data['countries_menu'] = $this->Location_model->get_countries_menu(); if (!empty($data['country_id'])) { $data['zones_menu'] = $this->Location_model->get_zones_menu($data['country_id']); } else { $data['zones_menu'] = $this->Location_model->get_zones_menu(array_shift(array_keys($data['countries_menu']))); } $data['page_title'] = lang('common_jcart_configuration'); if ($this->form_validation->run() == FALSE) { $data['error'] = validation_errors(); $this->view($this->config->item('admin_folder') . '/settings', $data); } else { $this->session->set_flashdata('message', lang('config_updated_message')); $save = $this->input->post(); //fix boolean values $save['ssl_support'] = $this->input->post('ssl_support'); $save['require_login'] = $this->input->post('require_login'); $save['new_customer_status'] = $this->input->post('new_customer_status'); $save['allow_os_purchase'] = $this->input->post('allow_os_purchase'); $save['tax_shipping'] = $this->input->post('tax_shipping'); $this->Settings_model->save_settings('jcart', $save); redirect(config_item('admin_folder') . '/settings'); } }
<?php var_dump(locale_get_display_name(str_repeat("a", 300), null)); var_dump(locale_get_display_name(str_repeat("a", 512), null)); var_dump(locale_get_display_name(str_repeat("a", 600), null));
/** * Set progress text for Progress flash dialog. * * @param $options tableau d'options. * @access protected * @return void * * @author Etienne de Longeaux <*****@*****.**> */ protected function renderlistAction($options = null) { if (!isset($options['class']) || empty($options['class'])) { throw ExtensionException::optionValueNotSpecified('class', __CLASS__); } if (!isset($options['img-arrow']) || empty($options['img-arrow'])) { throw ExtensionException::optionValueNotSpecified('img-arrow', __CLASS__); } $em = $this->container->get('doctrine')->getManager(); $locale = $this->container->get('request')->getLocale(); $entities = $em->getRepository("SfynxAuthBundle:Langue")->getAllEnabled($locale, 'object', false); // if the file doesn't exist, we call an exception $img = "bundles/sfynxtemplate/images/arrow/" . $options['img-arrow']; $is_file_exist = realpath($this->container->get('kernel')->getRootDir() . '/../web/' . $img); if (!$is_file_exist) { throw ExtensionException::FileUnDefined('img', __CLASS__); } $Urlpath = $this->container->get('templating.helper.assets')->getUrl($img); // We open the buffer. ob_start(); ?> <div class="clear"> </div> <div class="acc-line"> </div> <a href="" class="language-subtitle">Local language</a> <div class="clear"> </div> <div class="acc-line"> </div> <a href=""><?php echo locale_get_display_name(strtolower($locale), strtolower($locale)); ?> </a> <div class="clear"> </div> <div class="acc-line"> </div> <a href="" class="language-subtitle"><?php echo $this->container->get('translator')->trans('pi.form.label.field.other'); ?> </a> <?php foreach ($entities as $key => $entity) { $url = $this->container->get('router')->generate('pi_layout_choisir_langue', array('langue' => $entity->getId())); if ($entity->getId() != $locale) { $name_language = locale_get_display_name(strtolower($entity->getId()), strtolower($locale)); ?> <div class="clear"> </div> <div class="acc-line"> </div> <a href="<?php echo $url; ?> " id="lang_select_<?php echo $entity->getId(); ?> " title="<?php echo $name_language; ?> "><?php echo $name_language; ?> </a> <?php } } ?> <?php // We retrieve the contents of the buffer. $_content = ob_get_contents(); // We clean the buffer. ob_clean(); // We close the buffer. ob_end_flush(); return $_content; }
?> <div class="lang-quick-links"> <?php foreach ($lang_list as $lang => $locale) { ?> <a href="<?php echo base_url() . $lang . $path; ?> " lang="<?php echo $lang; ?> " class="lang-link<?php echo $lang == $lang_prefix ? ' active-lang' : ''; ?> "><?php echo locale_get_display_name($lang, $lang); ?> </a> · <?php } ?> <i class="icon-language"></i> </div> <?php } ?> <?php if (isset($is_authenticated)) { ?> <div class="auth-quick-links"> <?php
/** * Get English name of the language. In some situation, users are using an * interface of unknown language. They need to know how to jump out. * * @param string $locale * @return string */ public static function englishName($locale) { return locale_get_display_name($locale, 'en'); }