diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-10-02 09:54:35 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-10-02 10:01:33 +0200 |
commit | 17ab8e6c397011059b589da72a5d59cce8b65c7d (patch) | |
tree | a05d8b73b7d88952bc6c337d2bf2543cce8ed0b2 /apps/files_sharing/lib | |
parent | f3864c5444a7e56602d25d82ad13c0d79522c97d (diff) | |
download | nextcloud-server-17ab8e6c397011059b589da72a5d59cce8b65c7d.tar.gz nextcloud-server-17ab8e6c397011059b589da72a5d59cce8b65c7d.zip |
Use shorter text on the sidebar for files_sharing activities
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/activity.php | 66 |
1 files changed, 63 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/activity.php b/apps/files_sharing/lib/activity.php index 63ac2e90b2a..6f0294bcb71 100644 --- a/apps/files_sharing/lib/activity.php +++ b/apps/files_sharing/lib/activity.php @@ -24,6 +24,8 @@ namespace OCA\Files_Sharing; use OCP\Activity\IExtension; +use OCP\Activity\IManager; +use OCP\IL10N; use OCP\IURLGenerator; use OCP\L10N\IFactory; @@ -67,13 +69,18 @@ class Activity implements IExtension { /** @var IURLGenerator */ protected $URLGenerator; + /** @var IManager */ + protected $activityManager; + /** * @param IFactory $languageFactory * @param IURLGenerator $URLGenerator + * @param IManager $activityManager */ - public function __construct(IFactory $languageFactory, IURLGenerator $URLGenerator) { + public function __construct(IFactory $languageFactory, IURLGenerator $URLGenerator, IManager $activityManager) { $this->languageFactory = $languageFactory; $this->URLGenerator = $URLGenerator; + $this->activityManager = $activityManager; } protected function getL10N($languageCode = null) { @@ -149,9 +156,30 @@ class Activity implements IExtension { * @return string|false */ public function translate($app, $text, $params, $stripPath, $highlightParams, $languageCode) { + if ($app !== self::FILES_SHARING_APP) { + return false; + } + $l = $this->getL10N($languageCode); - if ($app === self::FILES_SHARING_APP) { + if ($this->activityManager->isFormattingFilteredObject()) { + $translation = $this->translateShort($text, $l, $params); + if ($translation !== false) { + return $translation; + } + } + + return $this->translateLong($text, $l, $params); + } + + /** + * @param string $text + * @param IL10N $l + * @param array $params + * @return bool|string + */ + protected function translateLong($text, IL10N $l, array $params) { + switch ($text) { case self::SUBJECT_REMOTE_SHARE_RECEIVED: if (sizeof($params) === 2) { @@ -186,12 +214,44 @@ class Activity implements IExtension { case self::SUBJECT_SHARED_EMAIL: return (string) $l->t('You shared %1$s with %2$s', $params); } - } return false; } /** + * @param string $text + * @param IL10N $l + * @param array $params + * @return bool|string + */ + protected function translateShort($text, IL10N $l, array $params) { + switch ($text) { + case self::SUBJECT_PUBLIC_SHARED_FOLDER_DOWNLOADED: + case self::SUBJECT_PUBLIC_SHARED_FILE_DOWNLOADED: + return (string) $l->t('Downloaded via public link'); + case self::SUBJECT_SHARED_USER_SELF: + return (string) $l->t('Shared with %2$s', $params); + case self::SUBJECT_SHARED_GROUP_SELF: + return (string) $l->t('Shared with group %2$s', $params); + case self::SUBJECT_RESHARED_USER_BY: + return (string) $l->t('Shared with %3$s by %2$s', $params); + case self::SUBJECT_RESHARED_GROUP_BY: + return (string) $l->t('Shared with group %3$s by %2$s', $params); + case self::SUBJECT_RESHARED_LINK_BY: + return (string) $l->t('Shared via link by %2$s', $params); + case self::SUBJECT_SHARED_WITH_BY: + return (string) $l->t('Shared by %2$s', $params); + case self::SUBJECT_SHARED_LINK_SELF: + return (string) $l->t('Shared via public link'); + case self::SUBJECT_SHARED_EMAIL: + return (string) $l->t('Shared with %2$s', $params); + + default: + return false; + } + } + + /** * The extension can define the type of parameters for translation * * Currently known types are: |