[icinga-checkins] icinga.org: icingaweb2/feature/translation-catalog-object-13012: CatalogHeader: Use strtr instead of resolvedEscapedCharacters

git at icinga.org git at icinga.org
Wed Nov 23 15:18:18 CET 2016


Module: icingaweb2
Branch: feature/translation-catalog-object-13012
Commit: 97bf708cfa56239b813b6a633a2a1c14e21eb7e2
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=97bf708cfa56239b813b6a633a2a1c14e21eb7e2

Author: Jennifer Mourek <jennifer.mourek at netways.de>
Date:   Wed Nov 23 15:17:07 2016 +0100

CatalogHeader: Use strtr instead of resolvedEscapedCharacters

refs #13012

---

 .../library/Translation/Catalog/CatalogHeader.php  |   27 +-------------------
 1 file changed, 1 insertion(+), 26 deletions(-)

diff --git a/modules/translation/library/Translation/Catalog/CatalogHeader.php b/modules/translation/library/Translation/Catalog/CatalogHeader.php
index 0aeeed8..8442ebf 100644
--- a/modules/translation/library/Translation/Catalog/CatalogHeader.php
+++ b/modules/translation/library/Translation/Catalog/CatalogHeader.php
@@ -172,38 +172,13 @@ class CatalogHeader implements ArrayAccess
         $entries[] = "msgid \"\"\nmsgstr \"\"";
         foreach ($this->headers as $key => $value)
         {
-            $entries[] = '"' . $this->escapeCharacters(sprintf('%s: %s', $key, $value)) . '\n"';
+            $entries[] = '"' . strtr(sprintf('%s: %s', $key, $value), array_flip(CatalogParser::$escapedChars)) . '\n"';
         }
 
         return implode("\n", $entries);
     }
 
     /**
-     * Escape characters
-     *
-     * @param   string  $string
-     *
-     * @return  string
-     */
-    protected function escapeCharacters($string)
-    {
-        $escapedChars = array(
-            "\n" => '\\n',
-            '"'  => '\\"',
-            "\t" => '\\t',
-            "\r" => '\\r',
-            "\\" => '\\'
-        );
-
-        foreach ($escapedChars as $key => $value)
-        {
-            $string = str_replace($key, $value, $string);
-        }
-
-        return $string;
-    }
-
-    /**
      * @see CatalogHeader::render()
      */
     public function __toString()



More information about the icinga-checkins mailing list