public translate ( string $id, string $originalLabel = null, array $arguments = [], string $source = 'Main', string $package = null, mixed $quantity = null, string $locale = null ) : string | ||
$id | string | Id to use for finding translation (trans-unit id in XLIFF) |
$originalLabel | string | The original translation value (the untranslated source string). |
$arguments | array | Numerically indexed array of values to be inserted into placeholders |
$source | string | Name of file with translations |
$package | string | Target package key. If not set, the current package key will be used |
$quantity | mixed | A number to find plural form for (float or int), NULL to not use plural forms |
$locale | string | An identifier of locale to use (NULL for use the default locale) |
return | string | Translated label or source label / ID key |
public function translate($id, $originalLabel = null, array $arguments = [], $source = 'Main', $package = null, $quantity = null, $locale = null)
{
if ($originalLabel === null && $arguments === [] && $source === 'Main' && $package === null && $quantity === null && $locale === null) {
return preg_match(self::I18N_LABEL_ID_PATTERN, $id) === 1 ? $this->translateByShortHandString($id) : $id;
}
return $this->translateByExplicitlyPassedOrderedArguments($id, $originalLabel, $arguments, $source, $package, $quantity, $locale);
}
/** * Render user initials or an abbreviated name for a given username. If the account was deleted, use the username as fallback. * * @param string $format Supported are "fullFirstName" and "initials" * @return string */ public function render($format = 'initials') { if (!in_array($format, array('fullFirstName', 'initials', 'fullName'))) { throw new \InvalidArgumentException(sprintf('Format "%s" given to history:userInitials(), only supporting "fullFirstName", "initials" and "fullName".', $format), 1415705861); } $username = $this->renderChildren(); /* @var $requestedUser Person */ $requestedUser = $this->domainUserService->getUser($username); if ($requestedUser === null || $requestedUser->getName() === null) { return $username; } $currentUser = $this->userService->getBackendUser(); if ($currentUser) { if ($currentUser === $requestedUser) { $translationHelper = new TranslationHelper(); $you = $translationHelper->translate('you', null, [], 'Main', 'Neos.Neos'); } } switch ($format) { case 'initials': return mb_substr($requestedUser->getName()->getFirstName(), 0, 1) . mb_substr($requestedUser->getName()->getLastName(), 0, 1); case 'fullFirstName': return isset($you) ? $you : $requestedUser->getName()->getFirstName() . ' ' . mb_substr($requestedUser->getName()->getLastName(), 0, 1) . '.'; case 'fullName': return isset($you) ? $you : $requestedUser->getName()->getFullName(); } }