本文整理汇总了PHP中Zend_Translate::_方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate::_方法的具体用法?PHP Zend_Translate::_怎么用?PHP Zend_Translate::_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Translate
的用法示例。
在下文中一共展示了Zend_Translate::_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _addHeadTitle
/**
* Add a translated message to headtitle
* @param string $msg
* @return App_Controller_Action
*/
protected function _addHeadTitle($msg)
{
$separator = " - ";
$msg = self::$_translate->_($msg);
$this->view->headTitle($separator . $msg);
return $this;
}
示例2: getMessages
public function getMessages(\Zend_Translate $t)
{
if ($this->checkedRespondentTracks) {
$messages[] = sprintf($t->_('Checked %d tracks.'), $this->checkedRespondentTracks);
}
if ($this->checkedTokens || !$this->checkedRespondentTracks) {
$messages[] = sprintf($t->_('Checked %d tokens.'), $this->checkedTokens);
}
if ($this->hasChanged()) {
if ($this->surveyCompletionChanges) {
$messages[] = sprintf($t->_('Answers changed by survey completion event for %d tokens.'), $this->surveyCompletionChanges);
}
if ($this->resultDataChanges) {
$messages[] = sprintf($t->_('Results and timing changed for %d tokens.'), $this->resultDataChanges);
}
if ($this->roundCompletionChanges) {
$messages[] = sprintf($t->_('%d token round completion events caused changed to %d tokens.'), $this->roundCompletionCauses, $this->roundCompletionChanges);
}
if ($this->tokenDateChanges) {
$messages[] = sprintf($t->_('%2$d token date changes in %1$d tracks.'), $this->tokenDateCauses, $this->tokenDateChanges);
}
if ($this->roundChangeUpdates) {
$messages[] = sprintf($t->_('Round changes propagated to %d tokens.'), $this->roundChangeUpdates);
}
if ($this->deletedTokens) {
$messages[] = sprintf($t->_('%d tokens deleted by round changes.'), $this->deletedTokens);
}
if ($this->createdTokens) {
$messages[] = sprintf($t->_('%d tokens created to by round changes.'), $this->createdTokens);
}
} else {
$messages[] = $t->_('No tokens were changed.');
}
return $messages;
}
示例3: isValid
/**
* Returns true if and only if $value meets the validation requirements
*
* If $value fails validation, then this method returns false, and
* getMessages() will return an array of messages that explain why the
* validation failed.
*
* @param mixed $value
* @param mixed $content
* @return boolean
* @throws \Zend_Validate_Exception If validation of $value is impossible
*/
public function isValid($value, $context = array())
{
$this->_message = null;
$user = $this->_userSource->getUser();
if (!($user->isActive() && $user->canResetPassword() && $user->isAllowedOrganization($context['organization']))) {
$this->_message = $this->translate->_('User not found or no e-mail address known or user cannot be reset.');
}
return (bool) (!$this->_message);
}
示例4: _checkDir
/**
* Open the dir, suppressing possible errors and try to
* create when it does not exist
*
* @param type $directory
* @return Directory
*/
protected function _checkDir($directory)
{
$eDir = @dir($directory);
if (false == $eDir) {
// Dir does probably not exist
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true)) {
\MUtil_Echo::pre(sprintf($this->translate->_('Directory %s not found and unable to create'), $directory), 'OpenRosa ERROR');
} else {
$eDir = @dir($directory);
}
}
}
return $eDir;
}
示例5: getContact
/**
* getContact
* @author Cornelius Hansjakob <cha@massiveart.com>
* @return string
*/
public function getContact($strTitle = '')
{
$strReturn = '';
$objPageContacts = $this->objPage->getContactsValues('contact');
if (count($objPageContacts) > 0) {
$strReturn .= '
<div class="contact">
<h3>' . ($strTitle != '' ? $strTitle : $this->objTranslate->_('Contact')) . '</h3>';
foreach ($objPageContacts as $objContact) {
$strReturn .= '
<div class="item">
<div class="name">' . htmlentities(($objContact->acTitle != '' ? $objContact->acTitle . ' ' : '') . $objContact->title, ENT_COMPAT, $this->core->sysConfig->encoding->default) . '</div>
<div class="position">' . htmlentities($objContact->position, ENT_COMPAT, $this->core->sysConfig->encoding->default) . '</div>
<!--<div class="address">
' . strip_tags($objContact->street) . '</br>
' . $objContact->zip . ' ' . $objContact->city . '</br>
' . htmlentities($objContact->countryTitle, ENT_COMPAT, $this->core->sysConfig->encoding->default) . '
</div>-->
<div class="numbers">
' . ($objContact->phone != '' ? $this->objTranslate->_('Tel') . '. ' . $objContact->phone . '<br/>' : '') . '
' . ($objContact->fax != '' ? $this->objTranslate->_('Fax') . ' ' . $objContact->fax : '') . '
</div>
<div class="mail">
<a href="mailto:' . $objContact->email . '">' . $this->objTranslate->_('Email') . '</a>
</div>
</div>';
}
$strReturn .= '
</div">';
}
return $strReturn;
}
示例6: _updateImage
private function _updateImage()
{
$this->_helper->viewRenderer->setNoRender(true);
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
$return = array('msg' => '', 'file' => array('name' => '', 'size' => '', 'url' => ''));
if ($this->getRequest()->isPost()) {
$allowedExtensions = null;
$maxSize = 999999;
$path = '';
$options = $this->_getBootstrapOptions();
// UPLOAD of image
$domainImage = new Media_Domain_Image();
$title = 'person_' . $this->_getParam('id');
$file = $domainImage->handleUpload(APPLICATION_DATA_PATH, array('AllowedExtensions' => $options['allowedExtensions'], 'SizeLimit' => $options['maxSize'], 'Dimensions' => $options['dimensions']));
if (isset($file['error'])) {
$return['error'] = $file['error'];
} else {
// MEDIA MODEL
$image = new Media_Model_Image();
$image->setFile($file['name']);
$image->setFilesize($file['size']);
$image->setMimetype($file['type']);
$image->setTitle($title);
// RECOVER Media from Person
$domainPerson = new Persons_Domain_Person();
$person = $domainPerson->getById($this->_getParam('id'));
$mp = $person->getMedia();
$createPersonMedia = !isset($mp) || $mp->getId() == null;
if (!$createPersonMedia) {
$image->setId($mp->getId());
}
$domainImage->setImage($image);
// DELETE previous image file from disk, only if they are not the same
if (!$createPersonMedia) {
if ($mp->getFile() != $image->getFile()) {
$domainImage->setImage($mp);
$domainImage->deleteFile();
$domainImage->setImage($image);
}
}
try {
// persisting media
$imgId = $domainImage->save();
// persisting person media
$image->setId($imgId);
$person->setMedia($image);
$domainPerson->setPerson($person);
if ($createPersonMedia) {
$domainPerson->createImageRelation();
}
$return['msg'] = $this->_translate->_('File successfully uploaded');
$return['file'] = $file;
} catch (Exception $e) {
echo json_encode(array('error' => $e->getMessage()));
}
}
echo json_encode($return);
}
}
示例7: _
/**
* Hook for SECTION: i18n (translation)
*/
function _($msg)
{
/////////////////////////////
// ==> SECTION: i18n <==
// Need volunteers to help create translations for the catalog in data/zfdemo.mo
// Nice tool to help manage the gettext catalog: http://www.poedit.net/
static $translator = null;
if ($translator === null) {
require_once 'Zend/Translate.php';
$registry = Zend_Registry::getInstance();
$translator = new Zend_Translate('gettext', $registry['dataDir'] . 'zfdemo.mo', $registry['userLocale']);
}
if (func_num_args() === 1) {
return $translator->_($msg);
} else {
$args = func_get_args();
array_shift($args);
return vsprintf($translator->_($msg), $args);
}
/////////////////////////////
// ==> SECTION: mvc <==
if (func_num_args() === 1) {
return $msg;
} else {
$args = func_get_args();
array_shift($args);
return vsprintf($msg, $args);
}
}
示例8: ajaxFormProcessor
/**
* Create Modal dialog business logic
* @param App_Form $form
* @param array $options
*/
public function ajaxFormProcessor(App_Form $form, $options)
{
$params = $this->_getAllParams();
$subaction = isset($params['subaction']) ? $params['subaction'] : null;
switch ($subaction) {
case 'submit':
if (!$form->isValid($params)) {
$this->view->isValid = $form->isValid($params);
$this->view->message = $form->getErrorMessages();
} else {
$this->view->isValid = $form->isValid($params);
$modelClass = $options['model']['class'];
$modelMethod = $options['model']['method'];
// persist method
call_user_func(array($modelClass, $modelMethod), $params);
$this->setMessage(self::$_translate->_($options['success']['message']));
$this->createAjaxButton($options['success']['button']['title'], $options['success']['button']['action']);
if (isset($options['success']['redirect'])) {
$this->view->redirect = $this->baseUrl . $options['success']['redirect'];
}
break;
}
default:
$this->view->title = self::$_translate->_($options['title']);
$this->createAjaxButton(self::$_translate->_($options['button']), "submit", $params, $options['url']);
$this->view->form = $form->toArray();
}
}
示例9: translate
static function translate($locale_code, $module_name, $key, $replace = null, $do_translation = true) {
// DON'T EVER LEAVE THIS UNCOMMENTED
// ob_clean();
// can be useful for debugging since using dd() will dump out into the existing markup and be hard to see
// but this clears out all the other markup so the debug data can be seen clearly
$translation = $key;
if ($do_translation) {
if (RivetyCore_Registry::get('enable_localization') == '1'
&& !is_null($module_name) && trim($module_name) != ""
&& !is_null($key) && trim($key) != "") {
$locale_code = RivetyCore_Translate::cleanZendLocaleCode($locale_code);
// TODO: account for core rivety module
$path_to_csv = RivetyCore_Registry::get('basepath')."/modules/".$module_name."/languages/".$locale_code.".csv";
if (file_exists($path_to_csv)) {
try {
$translate = new Zend_Translate("csv", $path_to_csv, $locale_code, array('delimiter' => ","));
$translation = $translate->_($key);
// this next bit will populate the locale file with untranslated terms
// so it's easier for someone to go through and translate them
if (RivetyCore_Registry::get('auto_populate_language_files') == '1') {
if (!$translate->isTranslated($key, true, $locale_code)) {
$key_no_quotes = str_replace('"', '"', $key);
$str = '"'.$key_no_quotes.'","'.$key_no_quotes.'"'."\n";
file_put_contents($path_to_csv, $str, FILE_APPEND);
}
}
} catch (Exception $e) {
$translation = $key;
}
} else {
// create the file
file_put_contents($path_to_csv, $key.','.$key);
}
}
}
$output = "";
if (is_null($replace)) {
// no replace, no sprintf
$output = $translation;
} else {
if (is_array($replace)) {
if (count($replace) > 1) {
// there are multiple indices, use vsprintf
$output = vsprintf($translation, $replace);
} else {
// there's only one index, use the cheaper sprintf instead
$output = sprintf($translation, $replace[0]);
}
} else {
// $replace is not an array, so try using it straight
$output = sprintf($translation, $replace);
}
}
return $output;
}
示例10: getCampo
/**
* Retorna o elemento da lista para ser adicionado quando necessário
*
* @param $sNome
* @return null
* @throws Exception
*/
public static function getCampo($sNome)
{
if (isset(self::$aCampos[$sNome])) {
return self::$aCampos[$sNome];
} else {
throw new Exception(self::$oTranslate->_(sprintf('O elemento "%s" não foi encontrado.', $sNome)));
}
}
示例11: getDataLoaded
public function getDataLoaded()
{
if ($this->token) {
if (parent::getDataLoaded()) {
return true;
} else {
return false;
}
} else {
$this->addMessage($this->translate->_('Token not found'));
return false;
}
}
示例12: numCount
/**
* Test the password for minimum number of numeric characters.
*
* @param mixed $parameter
* @param string $password
*/
protected function numCount($parameter, $password)
{
$len = intval($parameter);
if ($len) {
$results = array();
// Not used but required
$count = preg_match_all('/[0-9]/', $password, $results);
if ($len > 0 && $count < $len) {
$this->_addError(sprintf($this->translate->plural('should contain at least one number', 'should contain at least %d numbers', $len), $len));
} elseif ($len < 0 && ($count > 0 || null === $password)) {
$this->_addError($this->translate->_('may not contain numbers'));
}
}
}
示例13: isValidToken
/**
* Seperate the incorrect tokens from the right tokens
*
* @param mixed $value
* @return boolean
*/
protected function isValidToken($value)
{
// Make sure the value has the right format
$value = $this->tracker->filterToken($value);
$library = $this->tracker->getTokenLibrary();
$format = $library->getFormat();
$reuse = $library->hasReuse() ? $library->getReuse() : -1;
if (strlen($value) !== strlen($format)) {
$this->_messages = sprintf($this->translate->_('Not a valid token. The format for valid tokens is: %s.'), $format);
return false;
}
$token = $this->tracker->getToken($value);
if ($token && $token->exists) {
$currentDate = new \MUtil_Date();
if ($completionTime = $token->getCompletionTime()) {
// Reuse means a user can use an old token to check for new surveys
if ($reuse >= 0) {
// Oldest date AFTER completiondate. Oldest date is today minus reuse time
if ($completionTime->diffDays($currentDate) <= $reuse) {
// It is completed and may still be used to look
// up other valid tokens.
return true;
}
}
$this->_messages = $this->translate->_('This token is no longer valid.');
return false;
}
$fromDate = $token->getValidFrom();
if (null === $fromDate || $currentDate->isEarlier($fromDate)) {
// Current date is BEFORE from date
$this->_messages = $this->translate->_('This token cannot (yet) be used.');
return false;
}
if ($untilDate = $token->getValidUntil()) {
if ($currentDate->isLater($untilDate)) {
//Current date is AFTER until date
$this->_messages = $this->translate->_('This token is no longer valid.');
return false;
}
}
return true;
} else {
$this->_messages = $this->translate->_('Unknown token.');
return false;
}
}
示例14: initSecurity
/**
* Init Security
*/
protected function initSecurity()
{
$user = $this->getUser()->getBean();
if ($user == null) {
$this->_redirect('auth/view-login');
} elseif ($user->isInactive()) {
$this->setFlash('warning', $this->i18n->_('This user has been disabled'));
$this->_redirect('auth/view-login');
}
if (!$this->getAcl()->isAllowed($this->getUser()->getAccessRole()->getIdAccessRole(), $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName())) {
$this->setFlash('warning', 'You are not allowed to check this section');
$this->_redirect('index');
// throw new AuthException('Acceso Restringido');
}
$this->view->systemUser = $this->getUser()->getBean();
$this->view->systemAccessRole = $this->getUser()->getAccessRole();
}
示例15: _
/**
* @param string message id
* @param mixed ...args a long list of params
*/
public static function _($message)
{
//if ( !is_null(self::$_stringsWriter)) self::$_stringsWriter->_($message);
if (!is_null(self::$_translator)) {
if (false && APPLICATION_ENV == 'development') {
return "#(" . self::$_translator->_($message) . ")";
} else {
$return = self::$_translator->_($message);
if (func_num_args() > 1) {
$args = func_get_args();
array_shift($args);
// remove warning output
if ($message != $return) {
$return = @vsprintf($return, $args);
} else {
$return = "#({$return}, " . implode(', ', $args) . ")";
}
}
return $return;
}
}
}