Commit 7bf9b9a5 authored by catch's avatar catch
Browse files

Issue #2555825 by stefan.r, cilefen: Remove SafeMarkup::set call from TranslationManager::translate

parent c9072a41
...@@ -142,10 +142,15 @@ public function getStringTranslation($langcode, $string, $context) { ...@@ -142,10 +142,15 @@ public function getStringTranslation($langcode, $string, $context) {
public function translate($string, array $args = array(), array $options = array()) { public function translate($string, array $args = array(), array $options = array()) {
$string = $this->doTranslate($string, $options); $string = $this->doTranslate($string, $options);
if (empty($args)) { if (empty($args)) {
// This is assumed to be safe because translate should only be called // We add the string to the safe list as opposed to making it an object
// with strings defined in code. // implementing SafeStringInterface as we may need to call __toString()
// on the object before render time, at which point the string ceases to
// be safe, and working around this would require significant rework.
// Adding this string to the safe list is assumed to be safe because
// translate() should only be called with strings defined in code.
// @see \Drupal\Core\StringTranslation\TranslationInterface::translate() // @see \Drupal\Core\StringTranslation\TranslationInterface::translate()
return SafeMarkup::set($string); SafeMarkup::setMultiple([$string => ['html' => TRUE]]);
return $string;
} }
else { else {
return SafeMarkup::format($string, $args); return SafeMarkup::format($string, $args);
......
...@@ -580,7 +580,7 @@ protected function listLanguages($flags = LanguageInterface::STATE_ALL, array $c ...@@ -580,7 +580,7 @@ protected function listLanguages($flags = LanguageInterface::STATE_ALL, array $c
// Add real languages. // Add real languages.
foreach ($languages as $id => $language) { foreach ($languages as $id => $language) {
$list[$id] = $this->t($language->getName()); $list[$id] = $language->getName();
} }
return $list; return $list;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment