本文整理汇总了PHP中OC_L10N::t方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_L10N::t方法的具体用法?PHP OC_L10N::t怎么用?PHP OC_L10N::t使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_L10N
的用法示例。
在下文中一共展示了OC_L10N::t方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatDateSpanData
public function formatDateSpanData()
{
$time = 1416916800;
// Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
$deL10N = new \OC_L10N('lib', 'de');
return array(array('today', $this->getTimestampAgo($time, 30, 15), $time), array('yesterday', $this->getTimestampAgo($time, 0, 0, 0, 1), $time), array('4 days ago', $this->getTimestampAgo($time, 0, 0, 0, 4), $time), array('5 months ago', $this->getTimestampAgo($time, 0, 0, 0, 155), $time), array('2 years ago', $this->getTimestampAgo($time, 0, 0, 0, 0, 2), $time), array('today', $this->getTimestampAgo($time, 0, 0, 0, 0, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('yesterday', $this->getTimestampAgo($time, 30, 15, 3, 1, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('4 days ago', $this->getTimestampAgo($time, 30, 15, 3, 4, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('5 months ago', $this->getTimestampAgo($time, 30, 15, 3, 155, 1), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array('2 years ago', $this->getTimestampAgo($time, 30, 15, 3, 35, 3), $this->getTimestampAgo($time, 0, 0, 0, 0, 1)), array($deL10N->t('today'), new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000'), $deL10N), array($deL10N->t('yesterday'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n day ago', '%n days ago', 2), new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), $deL10N), array($deL10N->n('%n month ago', '%n months ago', 9), new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array($deL10N->n('%n year ago', '%n years ago', 2), new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000'), $deL10N), array('today', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 12:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('today', new \DateTime('Wed, 02 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Tue, 01 Oct 2013 23:59:58 +0000'), new \DateTime('Wed, 02 Oct 2013 23:59:59 +0000')), array('yesterday', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('yesterday', new \DateTime('Mon, 31 Dec 2012 00:00:00 +0000'), new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000')), array('2 days ago', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Mon, 30 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 31 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Tue, 01 Oct 2013 00:00:00 +0000')), array('last month', new \DateTime('Sun, 01 Sep 2013 00:00:00 +0000'), new \DateTime('Thu, 31 Oct 2013 00:00:00 +0000')), array('9 months ago', new \DateTime('Tue, 31 Dec 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('11 months ago', new \DateTime('Thu, 03 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Wed, 02 Oct 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('last year', new \DateTime('Tue, 01 Jan 2013 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')), array('2 years ago', new \DateTime('Sun, 01 Jan 2012 00:00:00 +0000'), new \DateTime('Thu, 02 Oct 2014 00:00:00 +0000')));
}
示例2: rename
/**
* rename a file
*
* @param string $dir
* @param string $oldname
* @param string $newname
* @return array
*/
public function rename($dir, $oldname, $newname)
{
$result = array('success' => false, 'data' => NULL);
// rename to "/Shared" is denied
if ($dir === '/' and $newname === 'Shared') {
$result['data'] = array('message' => $this->l10n->t("Invalid folder name. Usage of 'Shared' is reserved."));
// rename to existing file is denied
} else {
if ($this->view->file_exists($dir . '/' . $newname)) {
$result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir)));
} else {
if ($newname !== '.' and !($dir === '/' and $oldname === 'Shared') and $this->view->rename($dir . '/' . $oldname, $dir . '/' . $newname)) {
// successful rename
$meta = $this->view->getFileInfo($dir . '/' . $newname);
if ($meta['mimetype'] === 'httpd/unix-directory') {
$meta['type'] = 'dir';
} else {
$meta['type'] = 'file';
}
$fileinfo = array('id' => $meta['fileid'], 'mime' => $meta['mimetype'], 'size' => $meta['size'], 'etag' => $meta['etag'], 'directory' => $dir, 'name' => $newname, 'isPreviewAvailable' => \OC::$server->getPreviewManager()->isMimeSupported($meta['mimetype']), 'icon' => \OCA\Files\Helper::determineIcon($meta));
$result['success'] = true;
$result['data'] = $fileinfo;
} else {
// rename failed
$result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname)));
}
}
}
return $result;
}
示例3: rename
/**
* rename a file
*
* @param string $dir
* @param string $oldname
* @param string $newname
* @return array
*/
public function rename($dir, $oldname, $newname)
{
$result = array('success' => false, 'data' => NULL);
$normalizedOldPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $oldname);
$normalizedNewPath = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname);
// rename to non-existing folder is denied
if (!$this->view->file_exists($normalizedOldPath)) {
$result['data'] = array('message' => $this->l10n->t('%s could not be renamed as it has been deleted', array($oldname)), 'code' => 'sourcenotfound', 'oldname' => $oldname, 'newname' => $newname);
} else {
if (!$this->view->file_exists($dir)) {
$result['data'] = array('message' => (string) $this->l10n->t('The target folder has been moved or deleted.', array($dir)), 'code' => 'targetnotfound');
// rename to existing file is denied
} else {
if ($this->view->file_exists($normalizedNewPath)) {
$result['data'] = array('message' => $this->l10n->t("The name %s is already used in the folder %s. Please choose a different name.", array($newname, $dir)));
} else {
if ($newname !== '.' and $this->view->rename($normalizedOldPath, $normalizedNewPath)) {
// successful rename
$meta = $this->view->getFileInfo($normalizedNewPath);
$meta = \OCA\Files\Helper::populateTags(array($meta));
$fileInfo = \OCA\Files\Helper::formatFileInfo(current($meta));
$fileInfo['path'] = dirname($normalizedNewPath);
$result['success'] = true;
$result['data'] = $fileInfo;
} else {
// rename failed
$result['data'] = array('message' => $this->l10n->t('%s could not be renamed', array($oldname)));
}
}
}
}
return $result;
}
示例4: getLinkList
/**
* Get all items for the users we want to send an email to
*
* @return array Notification data (user => array of rows from the table)
*/
public function getLinkList()
{
$topEntries = [['id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')]];
if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) {
$topEntries[] = ['id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))];
$topEntries[] = ['id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))];
}
$additionalEntries = $this->activityManager->getNavigation();
$topEntries = array_merge($topEntries, $additionalEntries['top']);
return array('top' => $topEntries, 'apps' => $additionalEntries['apps']);
}
示例5: getNotificationTypes
/**
* @param \OC_L10N $l
* @return array Array "stringID of the type" => "translated string description for the setting"
*/
public function getNotificationTypes(\OC_L10N $l)
{
if (isset($this->notificationTypes[$l->getLanguageCode()])) {
return $this->notificationTypes[$l->getLanguageCode()];
}
$notificationTypes = array(self::TYPE_SHARED => $l->t('A file or folder has been <strong>shared</strong>'), self::TYPE_SHARE_CREATED => $l->t('A new file or folder has been <strong>created</strong>'), self::TYPE_SHARE_CHANGED => $l->t('A file or folder has been <strong>changed</strong>'), self::TYPE_SHARE_DELETED => $l->t('A file or folder has been <strong>deleted</strong>'), self::TYPE_SHARE_RESTORED => $l->t('A file or folder has been <strong>restored</strong>'));
// Allow other apps to add new notification types
$additionalNotificationTypes = $this->activityManager->getNotificationTypes($l->getLanguageCode());
$notificationTypes = array_merge($notificationTypes, $additionalNotificationTypes);
$this->notificationTypes[$l->getLanguageCode()] = $notificationTypes;
return $notificationTypes;
}
示例6: login
/**
* @brief Startup encryption backend upon user login
* @note This method should never be called for users using client side encryption
*/
public static function login($params)
{
$l = new \OC_L10N('files_encryption');
//check if all requirements are met
if (!Helper::checkRequirements()) {
$error_msg = $l->t("Missing requirements.");
$hint = $l->t('Please make sure that PHP 5.3.3 or newer is installed and that the OpenSSL PHP extension is enabled and configured properly. For now, the encryption app has been disabled.');
\OC_App::disable('files_encryption');
\OCP\Util::writeLog('Encryption library', $error_msg . ' ' . $hint, \OCP\Util::ERROR);
\OCP\Template::printErrorPage($error_msg, $hint);
}
$view = new \OC_FilesystemView('/');
// ensure filesystem is loaded
if (!\OC\Files\Filesystem::$loaded) {
\OC_Util::setupFS($params['uid']);
}
$util = new Util($view, $params['uid']);
// setup user, if user not ready force relogin
if (Helper::setupUser($util, $params['password']) === false) {
return false;
}
$encryptedKey = Keymanager::getPrivateKey($view, $params['uid']);
$privateKey = Crypt::decryptPrivateKey($encryptedKey, $params['password']);
if ($privateKey === false) {
\OCP\Util::writeLog('Encryption library', 'Private key for user "' . $params['uid'] . '" is not valid! Maybe the user password was changed from outside if so please change it back to gain access', \OCP\Util::ERROR);
}
$session = new \OCA\Encryption\Session($view);
$session->setPrivateKey($privateKey);
// Check if first-run file migration has already been performed
$ready = false;
if ($util->getMigrationStatus() === Util::MIGRATION_OPEN) {
$ready = $util->beginMigration();
}
// If migration not yet done
if ($ready) {
$userView = new \OC_FilesystemView('/' . $params['uid']);
// Set legacy encryption key if it exists, to support
// depreciated encryption system
if ($userView->file_exists('encryption.key') && ($encLegacyKey = $userView->file_get_contents('encryption.key'))) {
$plainLegacyKey = Crypt::legacyDecrypt($encLegacyKey, $params['password']);
$session->setLegacyKey($plainLegacyKey);
}
// Encrypt existing user files:
// This serves to upgrade old versions of the encryption
// app (see appinfo/spec.txt)
if ($util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])) {
\OC_Log::write('Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed', \OC_Log::INFO);
}
// Register successful migration in DB
$util->finishMigration();
}
return true;
}
示例7: validate
public function validate($config)
{
$errors = array();
if (empty($config['dbuser'])) {
$errors[] = $this->trans->t("%s enter the database username.", array($this->dbprettyname));
}
if (empty($config['dbname'])) {
$errors[] = $this->trans->t("%s enter the database name.", array($this->dbprettyname));
}
if (substr_count($config['dbname'], '.') >= 1) {
$errors[] = $this->trans->t("%s you may not use dots in the database name", array($this->dbprettyname));
}
return $errors;
}
示例8: delete
/**
* Delete the address book from backend
*
* @return bool
*/
public function delete()
{
if (!$this->hasPermission(\OCP\PERMISSION_DELETE)) {
throw new Exception(self::$l10n->t('You don\'t have permissions to delete the address book.'), Http::STATUS_FORBIDDEN);
}
return $this->backend->deleteAddressBook($this->getId());
}
示例9: joinParameterList
/**
* Returns a list of grouped parameters
*
* 2 parameters are joined by "and":
* => A and B
* Up to 5 parameters are joined by "," and "and":
* => A, B, C, D and E
* More than 5 parameters are joined by "," and trimmed:
* => A, B, C and #n more
*
* @param array $parameterList
* @param array $plainParameterList
* @param bool $highlightParams
* @return string
*/
protected function joinParameterList($parameterList, $plainParameterList, $highlightParams)
{
if (empty($parameterList)) {
return '';
}
$count = sizeof($parameterList);
$lastItem = array_pop($parameterList);
if ($count == 1) {
return $lastItem;
} else {
if ($count == 2) {
$firstItem = array_pop($parameterList);
return $this->l->t('%s and %s', array($firstItem, $lastItem));
} else {
if ($count <= 5) {
$list = implode($this->l->t(', '), $parameterList);
return $this->l->t('%s and %s', array($list, $lastItem));
}
}
}
$firstParams = array_slice($parameterList, 0, 3);
$firstList = implode($this->l->t(', '), $firstParams);
$trimmedParams = array_slice($plainParameterList, 3);
$trimmedList = implode($this->l->t(', '), $trimmedParams);
if ($highlightParams) {
return $this->l->n('%s and <strong class="tooltip" title="%s">%n more</strong>', '%s and <strong class="tooltip" title="%s">%n more</strong>', $count - 3, array($firstList, $trimmedList));
}
return $this->l->n('%s and %n more', '%s and %n more', $count - 3, array($firstList));
}
示例10: getBirthdayEvent
/**
* Generate an event to show in the calendar
*
* @return \Sabre\VObject\Component\VCalendar|null
*/
public function getBirthdayEvent()
{
if (!isset($this->BDAY)) {
return;
}
$birthday = $this->BDAY;
if ((string) $birthday) {
$title = str_replace('{name}', strtr((string) $this->FN, array('\\,' => ',', '\\;' => ';')), App::$l10n->t('{name}\'s Birthday'));
try {
$date = new \DateTime($birthday);
} catch (\Exception $e) {
continue;
}
$vevent = \Sabre\VObject\Component::create('VEVENT');
$vevent->add('DTSTART');
$vevent->DTSTART->setDateTime($date, \Sabre\VObject\Property\DateTime::DATE);
$vevent->add('DURATION', 'P1D');
$vevent->{'UID'} = $this->UID;
$vevent->{'RRULE'} = 'FREQ=YEARLY';
$vevent->{'SUMMARY'} = $title;
$vcal = \Sabre\VObject\Component::create('VCALENDAR');
$vcal->VERSION = '2.0';
$appinfo = \OCP\App::getAppInfo('contacts');
$appversion = \OCP\App::getAppVersion('contacts');
$vcal->PRODID = '-//ownCloud//NONSGML ' . $appinfo['name'] . ' ' . $appversion . '//EN';
$vcal->add($vevent);
return $vcal;
}
}
示例11: checkAdminUser
/**
* Check if the user is a admin, send json error msg if not
*/
public static function checkAdminUser()
{
self::checkLoggedIn();
if (!OC_Group::inGroup(OC_User::getUser(), 'admin')) {
$l = new OC_L10N('core');
self::error(array('data' => array('message' => $l->t('Authentication error'))));
exit;
}
}
示例12: getLinkList
/**
* Get all items for the users we want to send an email to
*
* @return array Notification data (user => array of rows from the table)
*/
public function getLinkList()
{
$topEntries = array(array('id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')), array('id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))), array('id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))), array('id' => 'shares', 'name' => (string) $this->l->t('Shares'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'shares'))));
$appFilterEntries = array(array('id' => 'files', 'name' => (string) $this->l->t('Files'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'files'))));
$additionalEntries = $this->activityManager->getNavigation();
$topEntries = array_merge($topEntries, $additionalEntries['top']);
$appFilterEntries = array_merge($appFilterEntries, $additionalEntries['apps']);
return array('top' => $topEntries, 'apps' => $appFilterEntries);
}
示例13: buildFileStorageStatistics
public static function buildFileStorageStatistics($dir)
{
// information about storage capacities
$storageInfo = \OC_Helper::getStorageInfo($dir);
$l = new \OC_L10N('files');
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize));
return array('uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'freeSpace' => $storageInfo['free'], 'usedSpacePercent' => (int) $storageInfo['relative']);
}
示例14: sendLinkShareMail
/**
* inform recipient about public link share
*
* @param string $recipient recipient email address
* @param string $filename the shared file
* @param string $link the public link
* @param int $expiration expiration date (timestamp)
* @return array $result of failed recipients
*/
public function sendLinkShareMail($recipient, $filename, $link, $expiration) {
$subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
$rs = explode(' ', $recipient);
$failed = array();
foreach ($rs as $r) {
try {
\OCP\Util::sendMail($r, $r, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
} catch (\Exception $e) {
\OCP\Util::writeLog('sharing', "Can't send mail with public link to $r: " . $e->getMessage(), \OCP\Util::ERROR);
$failed[] = $r;
}
}
return $failed;
}
示例15: getAddressBook
/**
* Get an address book from a specific backend.
*
* @param string $backendName
* @param string $addressbookid
* @return AddressBook|null
*/
public function getAddressBook($backendName, $addressbookid)
{
//\OCP\Util::writeLog('contacts', __METHOD__ . ': '. $backendName . ', ' . $addressbookid, \OCP\Util::DEBUG);
foreach (self::$addressBooks as $addressBook) {
if ($addressBook->getBackend()->name === $backendName && $addressBook->getId() === $addressbookid) {
return $addressBook;
}
}
$backend = self::getBackend($backendName, $this->user);
$info = $backend->getAddressBook($addressbookid);
if (!$info) {
throw new \Exception(self::$l10n->t('Address book not found'), 404);
}
$addressBook = new AddressBook($backend, $info);
self::$addressBooks[] = $addressBook;
return $addressBook;
}