private function PrivateMessageThreadMessageFormatter::translateKey in Private Message 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/PrivateMessageThreadMessageFormatter.php \Drupal\private_message\Plugin\Field\FieldFormatter\PrivateMessageThreadMessageFormatter::translateKey()
Translates a given key.
Parameters
string $type: The type of string being translated.
string $value: The value to be translated.
Return value
mixed
- If a translated value exists for the given type/value combination, a \Drupal\Core\StringTranslation\TranslatableMarkup object containing the translated value is returned.
- If only the type exists, but not the value, the untranslated value as a string is returned.
- If the type does not exist, the untranslated value is returned.
2 calls to PrivateMessageThreadMessageFormatter::translateKey()
- PrivateMessageThreadMessageFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ PrivateMessageThreadMessageFormatter.php - Returns a form to configure settings for the formatter.
- PrivateMessageThreadMessageFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ PrivateMessageThreadMessageFormatter.php - Returns a short summary for the current formatter settings.
File
- src/
Plugin/ Field/ FieldFormatter/ PrivateMessageThreadMessageFormatter.php, line 265
Class
- PrivateMessageThreadMessageFormatter
- Defines the private message thread message field formatter.
Namespace
Drupal\private_message\Plugin\Field\FieldFormatterCode
private function translateKey($type, $value) {
if ($type == 'order') {
$keys = [
'asc' => $this
->t('Ascending'),
'desc' => $this
->t('Descending'),
];
return isset($keys[$value]) ? $keys[$value] : $value;
}
return $value;
}