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


PHP Localization类代码示例

本文整理汇总了PHP中Localization的典型用法代码示例。如果您正苦于以下问题:PHP Localization类的具体用法?PHP Localization怎么用?PHP Localization使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getErrors

 public function getErrors(Config $cfg)
 {
     $i18n = Localization::getTranslator();
     $walletSettings = [];
     $emailSettings = [];
     $providerClass = '';
     try {
         $provider = $cfg->getWalletProvider();
         $providerClass = get_class($provider);
         $provider->verifyOwnership();
     } catch (Exception $e) {
         if (strpos($providerClass, 'CoinbaseWallet') !== false) {
             $walletSettings[] = ['id' => '#wallet-coinbaseApiKey-error', 'error' => $e->getMessage()];
         } else {
             $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $e->getMessage()];
         }
     }
     try {
         $t = new Swift_SmtpTransport('smtp.gmail.com', 465, 'ssl');
         $t->setUsername($cfg->getEmailUsername())->setPassword($cfg->getEmailPassword())->start();
     } catch (Exception $e) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $e->getMessage()];
     }
     $errors = [];
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrorsFromConfig($cfg);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }
开发者ID:kryptoc,项目名称:skyhook,代码行数:35,代码来源:ConfigVerifier.php

示例2: langA

function langA($name, $args)
{
    static $base = null;
    $value = Localization::instance()->lang($name);
    if (is_null($value)) {
        if (!Env::isDebugging()) {
            if (!$base instanceof Localization) {
                $base = new Localization();
                $base->loadSettings("en_us", ROOT . "/language");
            }
            $value = $base->lang($name);
        }
        if (is_null($value)) {
            $value = Localization::instance()->lang(str_replace(" ", "_", $name));
            if (is_null($value)) {
                $value = Localization::instance()->lang(str_replace("_", " ", $name));
                if (is_null($value)) {
                    return "Missing lang: {$name}";
                }
            }
        }
    }
    // We have args? Replace all {x} with arguments
    if (is_array($args) && count($args)) {
        $i = 0;
        foreach ($args as $arg) {
            $value = str_replace('{' . $i . '}', $arg, $value);
            $i++;
        }
        // foreach
    }
    // if
    // Done here...
    return $value;
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:35,代码来源:localization.php

示例3: translateCharacters

 /**
  * Performs character set and HTML character translations on the string.
  *
  * @access public
  * @param string       $string      required The string that is to be translated.
  * @param Localization $locale      required The locale object for doing the character set translation.
  * @param string       $toCharset   required Translate to this character set.
  * @param string       $fromCharset          Translate from this character set.
  * @return string The translated string.
  */
 public function translateCharacters($string, Localization $locale, $toCharset, $fromCharset = "UTF-8")
 {
     // perform character set translations on the string
     $string = $locale->translateCharset($string, $fromCharset, $toCharset);
     // perform HTML character translations on the string
     $string = from_html($string);
     return $string;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:18,代码来源:EmailFormatter.php

示例4: getLocale

 public function getLocale()
 {
     if (!isset($this->locale)) {
         $loc = new Localization();
         $this->locale = $loc->getCurrentLocale();
     }
     // if
     return $this->locale;
 }
开发者ID:TheProjecter,项目名称:openface,代码行数:9,代码来源:ApplicationContext.php

示例5: testAssignedUserName

 public function testAssignedUserName()
 {
     global $locale;
     require_once 'include/Localization/Localization.php';
     $locale = new Localization();
     $testName = $locale->getLocaleFormattedName($this->user->first_name, $this->user->last_name);
     $testTemplate = new EmailTemplate();
     $testTemplate->retrieve($this->emailTemplate->id);
     $this->assertEquals($testName, $testTemplate->assigned_user_name, 'Assert that the assigned_user_name is the locale formatted name value');
 }
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:10,代码来源:Bug48800Test.php

示例6: build_original_mail_info

	private function build_original_mail_info($original_mail, $type = 'plain') {
		$loc = new Localization();
		$loc->setDateTimeFormat("D, d M Y H:i:s O");
		if ($type == 'plain') {
			$cc_cell = $original_mail->getCc() == '' ? '' : "\n".lang('mail CC').": ".$original_mail->getCc();
			$str = "\n\n----- ".lang('original message')."-----\n".lang('mail from').": ".$original_mail->getFrom()."\n".lang('mail to').": ".$original_mail->getTo()."$cc_cell\n".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."\n".lang('mail subject').": ".$original_mail->getSubject()."\n\n";
		} else {
			$cc_cell = $original_mail->getCc() == '' ? '' : "<tr><td>".lang('mail CC').": ".$original_mail->getCc()."</td></tr>";
			$str = "<br><br><table><tr><td>----- ".lang('original message')." -----</td></tr><tr><td>".lang('mail from').": ".$original_mail->getFrom()."</td></tr><tr><td>".lang('mail to').": ".$original_mail->getTo()."</td></tr>$cc_cell<tr><td>".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."</td></tr><tr><td>".lang('mail subject').": ".$original_mail->getSubject()."</td></tr></table><br>";
		}		 
		return $str;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:12,代码来源:MailController.class.php

示例7: view

 public function view()
 {
     $locales = Localization::getAvailableInterfaceLanguageDescriptions();
     $this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN'));
     $this->set('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED', Config::get('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED'));
     $this->set('interfacelocales', $locales);
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:7,代码来源:multilingual.php

示例8: render

 /**
  * Renders the field
  *
  * @return string
  */
 function render()
 {
     $random_keys = array('name' => $this->field_id, 'latitude' => Helper::getRandomString(), 'longitude' => Helper::getRandomString());
     $values = array('name' => isset($this->field_data['name']) ? $this->field_data['name'] : '', 'latitude' => isset($this->field_data['latitude']) ? $this->field_data['latitude'] : '', 'longitude' => isset($this->field_data['longitude']) ? $this->field_data['longitude'] : '');
     $html = '<div class="map"';
     // add in per-field settings
     $settings = array();
     foreach ($this->field_config as $setting => $value) {
         if (!in_array($setting, $this->allowed_settings) || is_null($value)) {
             continue;
         }
         $settings[$setting] = $value;
     }
     // if we found something, add the configuration to the element
     if (count($settings)) {
         $html .= " data-location-configuration='" . json_encode($settings) . "'";
     }
     $html .= '></div>';
     $html .= '<div class="entry">';
     $html .= '	<div class="name">';
     $html .= '		<p>';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][name', array('display' => Localization::fetch('location_name')), $values['name'], NULL, NULL, $random_keys['name']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '	<div class="coordinates">';
     $html .= '		<p class="latitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][latitude', array('display' => Localization::fetch('latitude')), $values['latitude'], NULL, NULL, $random_keys['latitude']);
     $html .= '		</p>';
     $html .= '		<p class="longitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][longitude', array('display' => Localization::fetch('longitude')), $values['longitude'], NULL, NULL, $random_keys['longitude']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '</div>';
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:40,代码来源:ft.location.php

示例9: lang

/**
 * Shortcut function for retrieving single lang value
 *
 * @access public
 * @param string $name
 * @return string
 */
function lang($name)
{
    // Get function arguments and remove first one.
    $args = func_get_args();
    if (is_array($args)) {
        array_shift($args);
    }
    // if
    // Get value and if we have NULL done!
    if (plugin_active('i18n')) {
        $value = lang_from_db($name);
    } else {
        $value = Localization::instance()->lang($name);
    }
    if (is_null($value)) {
        return $value;
    }
    // if
    // We have args? Replace all %s with arguments
    if (is_array($args) && count($args)) {
        foreach ($args as $arg) {
            $value = str_replace_first('%s', $arg, $value);
        }
        // foreach
    }
    // if
    // Done here...
    return $value;
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:36,代码来源:localization.php

示例10: do_update

	public function do_update($pkgHandle = false) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			if ($pkgHandle) {
				$tests = Package::testForInstall($pkgHandle, false);
				if (is_array($tests)) {
					$tests = Package::mapError($tests);
					$this->set('error', $tests);
				} else {
					$p = Package::getByHandle($pkgHandle);
					$currentLocale = Localization::activeLocale();
					if ($currentLocale != 'en_US') {
						// Prevent the database records being stored in wrong language
						Localization::changeLocale('en_US');
					}
					try {
						$p->upgradeCoreData();
						if ($currentLocale != 'en_US') {
							Localization::changeLocale($currentLocale);
						}
						$p->upgrade();
						$this->set('message', t('The package has been updated successfully.'));
					} catch(Exception $e) {
						$this->set('error', $e);
					}
				}
			}
		}
		$this->view();
	}
开发者ID:nveid,项目名称:concrete5,代码行数:30,代码来源:update.php

示例11: __construct

 public function __construct($page, $comment_id, $type = 0)
 {
     $this->_localization = Localization::getInstance();
     $this->type = $type;
     $this->page = $page;
     $this->comment_id = $comment_id;
     $this->form_values['comment_text'] = isset($_POST['comment_text']) ? htmlspecialchars($_POST['comment_text']) : '';
     $this->form_values['name'] = isset($_POST['name']) ? htmlspecialchars($_POST['name']) : '';
     $this->form_values['email_hp'] = isset($_POST['email_hp']) ? htmlspecialchars($_POST['email_hp']) : '';
     $this->_form_session = 'comment_form_session_' . $this->comment_id . '_' . $this->type;
     if ($this->type == 1) {
         if (isset($_GET['get_5'])) {
             $this->current_page = intval($_GET['get_5']);
         } else {
             $this->current_page = 1;
         }
     } else {
         if (isset($_GET['get_1'])) {
             $this->current_page = intval($_GET['get_1']);
         } else {
             $this->current_page = 1;
         }
     }
     if ($this->current_page == 0) {
         $this->current_page = 1;
     }
     if (isset($_SESSION[$this->_form_session])) {
         $this->form_session = $_SESSION[$this->_form_session];
         $form_session_data['name'] = session_name();
         $form_session_data['id'] = session_id();
         $this->form_session_data = $form_session_data;
     }
 }
开发者ID:adartk,项目名称:phpsqlitecms,代码行数:33,代码来源:Comment.class.php

示例12: view

 public function view()
 {
     $this->requireAsset('javascript', 'jquery');
     $ml = Section::getList();
     $c = \Page::getCurrentPage();
     $al = Section::getBySectionOfSite($c);
     $languages = [];
     $locale = null;
     if ($al !== null) {
         $locale = $al->getLanguage();
     }
     if (!$locale) {
         $locale = \Localization::activeLocale();
         $al = Section::getByLocale($locale);
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($m->getLocale());
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('activeLanguage', $al ? $al->getCollectionID() : null);
     $dl = $this->app->make('multilingual/detector');
     $this->set('defaultLocale', $dl->getPreferredSection());
     $this->set('locale', $locale);
     $this->set('cID', $c->getCollectionID());
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:controller.php

示例13: testAndRunInstall

	protected function testAndRunInstall() {
		if (file_exists(DIR_CONFIG_SITE . '/site_install_user.php')) {
			require(DIR_CONFIG_SITE . '/site_install.php');
			@include(DIR_CONFIG_SITE . '/site_install_user.php');
			if (defined('ACTIVE_LOCALE') && Localization::activeLocale() !== ACTIVE_LOCALE) {
				Localization::changeLocale(ACTIVE_LOCALE);
			}
			$e = Loader::helper('validation/error');
			$e = $this->validateDatabase($e);
			if ($e->has()) {
				$this->set('error', $e);
			} else {
				$this->addHeaderItem(Loader::helper('html')->css('jquery.ui.css'));
				$this->addHeaderItem(Loader::helper('html')->javascript('jquery.ui.js'));
				if (defined('INSTALL_STARTING_POINT') && INSTALL_STARTING_POINT) { 
					$spl = Loader::startingPointPackage(INSTALL_STARTING_POINT);
				} else {
					$spl = Loader::startingPointPackage('standard');
				}
				$this->set('installPackage', $spl->getPackageHandle());
				$this->set('installRoutines', $spl->getInstallRoutines());
				$this->set('successMessage', t('Congratulations. concrete5 has been installed. You have been logged in as <b>%s</b> with the password you chose. If you wish to change this password, you may do so from the users area of the dashboard.', USER_SUPER, $uPassword));
			}
		}
	}
开发者ID:nveid,项目名称:concrete5,代码行数:25,代码来源:install.php

示例14: setupSiteInterfaceLocalization

 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
         return;
     }
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     // don't translate dashboard pages
     $dh = \Core::make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if (strlen($locale)) {
         \Localization::changeLocale($locale);
     }
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:25,代码来源:Detector.php

示例15: render

 public function render()
 {
     // Let's make sure they set an upload destination
     if (array_get($this->field_config, 'destination', false) === false) {
         throw new Exception("You need to set a destination for your File field.");
     }
     if ($this->field_data) {
         $file = Path::toAsset($this->field_data);
         $html = "<div class='file-field-container file-exists'>";
         $html .= "<div>";
         if (File::isImage(Path::fromAsset($this->field_data, true))) {
             $html .= "<img src='{$file}' height='58'>";
         }
         $html .= "<p>" . basename($this->field_data) . "</p>";
         $html .= "<a class='btn btn-small btn-remove-file' href='#'>" . Localization::fetch('remove') . "</a>";
         $html .= "</div>";
         $html .= $this->makeFileSelect($file);
     } else {
         $html = "<div class='file-field-container'>";
         $html .= "<div class='upload-file'>";
         $html .= "<p><input type='file' name='{$this->fieldname}' tabindex='{$this->tabindex}' value='' /></p>";
         $html .= $this->makeFileSelect();
         $html .= "</div>";
     }
     $html .= "</div>";
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:27,代码来源:ft.file.php


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