[icinga-checkins] icinga.org: icingaweb2/feature/po-file-parser-13011: CatalogParser: Add method resolveEscapedChars

git at icinga.org git at icinga.org
Fri Nov 4 09:32:39 CET 2016


Module: icingaweb2
Branch: feature/po-file-parser-13011
Commit: 667a787665056a17d65b789b384e419779c13f84
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=667a787665056a17d65b789b384e419779c13f84

Author: Jennifer Mourek <jennifer.mourek at netways.de>
Date:   Fri Nov  4 09:31:03 2016 +0100

CatalogParser: Add method resolveEscapedChars

---

 .../library/Translation/Catalog/CatalogParser.php  |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/translation/library/Translation/Catalog/CatalogParser.php b/modules/translation/library/Translation/Catalog/CatalogParser.php
index 72949aa..ae3c3f5 100644
--- a/modules/translation/library/Translation/Catalog/CatalogParser.php
+++ b/modules/translation/library/Translation/Catalog/CatalogParser.php
@@ -114,7 +114,7 @@ class CatalogParser
      * @param string    $lastDefault      Indicator key the line belongs to if multiline
      */
     protected function parseLine($line, &$currentEntry, &$lastDefault) {
-        $line = str_replace(PHP_EOL, '', $line);
+        $line = $this->resolveEscapedChars($line);
         foreach ($this->attributeIndicators as $key => $indicator) {
             if (strpos($line, $indicator) === 0) {
                 $line = substr($line, strlen($indicator));
@@ -153,4 +153,22 @@ class CatalogParser
             }
         }
     }
+
+    /**
+     * Resolve escaped characters in the given line
+     *
+     * @param string    $line   The current line of method parse
+     *
+     * @return string
+     */
+    protected function resolveEscapedChars($line) {
+        $line = str_replace(PHP_EOL, '', $line);
+        $line = str_replace('\"', '"', $line);
+        $line = str_replace('\n', "\n",  $line);
+        $line = str_replace('\t', "\t",  $line);
+        $line = str_replace('\r', "\r",  $line);
+        $line = str_replace('\$', "\$",  $line);
+
+        return $line;
+    }
 }



More information about the icinga-checkins mailing list