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


PHP Localization::getTranslator方法代码示例

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


在下文中一共展示了Localization::getTranslator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: send

 public function send($lastOverride = false)
 {
     $i18n = Localization::getTranslator();
     $lastFn = '/home/pi/phplog/last-tx-sent';
     $last = 0;
     if (file_exists($lastFn)) {
         $last = intval(trim(file_get_contents($lastFn)));
     }
     if ($lastOverride !== false) {
         $last = $lastOverride;
     }
     $csvMaker = Container::dispense('TransactionCSV');
     $config = Admin::volatileLoad()->getConfig();
     $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
     $msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('See attached for transaction log.'));
     $file = $csvMaker->save($last);
     if (!$file) {
         throw new Exception('Unable to save CSV');
     }
     $msg->attach(Swift_Attachment::fromPath($file));
     file_put_contents($lastFn, $csvMaker->getLastID());
     $mailer = Swift_Mailer::newInstance($transport);
     if (!$mailer->send($msg)) {
         throw new Exception('Unable to send: unkown cause');
     }
 }
开发者ID:oktoshi,项目名称:skyhook,代码行数:26,代码来源:CSVMailer.php

示例3: render

 /**
  * Imports symbol table into template file's execution context, rendering
  * as the file dictates
  *
  * @param array $symbols to import
  * @return void
  */
 public function render(array $symbols = array())
 {
     extract($symbols);
     unset($symbols);
     $html = new HTML();
     $i18n = Localization::getTranslator();
     include $this->getPage();
 }
开发者ID:RichAyotte,项目名称:skyhook,代码行数:15,代码来源:Template.php

示例4: send

 public function send()
 {
     $i18n = Localization::getTranslator();
     $config = Admin::volatileLoad()->getConfig();
     $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')->setUsername($config->getEmailUsername())->setPassword($config->getEmailPassword());
     $msg = Swift_Message::newInstance()->setSubject($config->getMachineName() . $i18n->_(': Transaction Log'))->setFrom([$config->getEmailUsername() => $config->getMachineName()])->setTo(array($config->getEmailUsername()))->setBody($i18n->_('There have been no transactions since the last email.'));
     $mailer = Swift_Mailer::newInstance($transport);
     if (!$mailer->send($msg)) {
         throw new Exception('Unable to send: unkown cause');
     }
 }
开发者ID:RichAyotte,项目名称:skyhook,代码行数:11,代码来源:HeartBeatMailer.php

示例5: getErrors

 public function getErrors(Post $post)
 {
     $i18n = Localization::getTranslator();
     //TODO: implement range checking on modifier values, and static pricing
     $walletSettings = [];
     if (empty($post['wallet']['id'])) {
         $walletSettings[] = ['id' => '#wallet-id-error', 'error' => $i18n->_('A valid Blockchain.info wallet id is required.')];
     }
     if (empty($post['wallet']['mainPass'])) {
         $walletSettings[] = ['id' => '#wallet-mainPass-error', 'error' => $i18n->_('Your respective Blockchain.info password is required.')];
     }
     if (empty($post['wallet']['fromAddress'])) {
         $walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('An address controlled by your Blockchain.info wallet is required to send from.')];
     } elseif (!AddressUtility::checkAddress($post['wallet']['fromAddress'])) {
         $walletSettings[] = ['id' => '#wallet-fromAddress-error', 'error' => $i18n->_('A valid Bitcoin address is required.')];
     }
     $emailUser = @$post['email']['username'];
     $emailSettings = [];
     if (empty($emailUser)) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('A valid email address is required.')];
     } elseif (filter_var($emailUser, FILTER_VALIDATE_EMAIL) !== $emailUser) {
         $emailSettings[] = ['id' => '#email-username-error', 'error' => $i18n->_('Email address entered is not valid.')];
     }
     if (empty($post['email']['password'])) {
         $emailSettings[] = ['id' => '#email-password-error', 'error' => $i18n->_('Email password is required.')];
     }
     $passwordSettings = [];
     if (strlen(@$post['admin_password']) < 5) {
         $passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Minimum password length is 5 characters.')];
     }
     if (@$post['admin_password'] !== @$post['confirm_admin_password']) {
         $passwordSettings[] = ['id' => '#password-error', 'error' => $i18n->_('Admin passwords must match')];
     }
     $transactionSettings = [];
     if (isset($post['transactions']['maximum'])) {
         if (!preg_match('#^[0-9]+$#', $post['transactions']['maximum'])) {
             $transactionSettings[] = ['id' => '#maximum-errors', 'error' => $i18n->_('Maximum transaction value must be a positive integer.')];
         }
     }
     $localeSettings = [];
     if (isset($post['locale'])) {
         if (!Localization::localePresent($post['locale'])) {
             $transactionSettings[] = ['id' => '#locale-errors', 'error' => $i18n->_('Unkown Locale.')];
         }
     }
     $errors = [];
     if (!empty($transactionSettings)) {
         $errors['#locale-settings'] = $localeSettings;
     }
     if (!empty($transactionSettings)) {
         $errors['#transaction-settings'] = $transactionSettings;
     }
     if (!empty($passwordSettings)) {
         $errors['#password-settings'] = $passwordSettings;
     }
     if (!empty($pricingSettings)) {
         $errors['#pricing-settings'] = self::getPricingErrors($post);
     }
     if (!empty($walletSettings)) {
         $errors['#wallet-settings'] = $walletSettings;
     }
     if (!empty($emailSettings)) {
         $errors['#email-settings'] = $emailSettings;
     }
     return $errors;
 }
开发者ID:oktoshi,项目名称:skyhook,代码行数:66,代码来源:ConfigValidator.php


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