aboutsummaryrefslogtreecommitdiffstats
path: root/util/po2php.php
diff options
context:
space:
mode:
authoranaqreon <tamanning@zoho.com>2014-12-30 16:06:35 -0600
committeranaqreon <tamanning@zoho.com>2014-12-30 16:06:35 -0600
commitb78a545a1056e6db9f4b6b4f262182b0a5c56e67 (patch)
tree515c2f742a5a39e18b00debf1849ee9703fa4a42 /util/po2php.php
parentd67c5a6ffd134602084a6dcb37b316bf768bf715 (diff)
parent43671a0a323afa758df56c06822ce3c46da026df (diff)
downloadvolse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.gz
volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.bz2
volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.zip
Merge pull request #1 from friendica/master
Pull from upstream
Diffstat (limited to 'util/po2php.php')
-rw-r--r--util/po2php.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/util/po2php.php b/util/po2php.php
index d3e6d190c..cf295d8cb 100644
--- a/util/po2php.php
+++ b/util/po2php.php
@@ -73,7 +73,7 @@ function po2php_run($argv, $argc) {
}
$match=Array();
preg_match("|\[([0-9]*)\] (.*)|", $l, $match);
- $out .= "\t".
+ $out .= "\t".
preg_replace_callback($escape_s_exp,'escape_s',$match[1])
." => "
.preg_replace_callback($escape_s_exp,'escape_s',$match[2]) .",\n";
@@ -83,7 +83,7 @@ function po2php_run($argv, $argc) {
if ($ink) {
- $k .= trim($l,"\"\r\n");
+ $k .= trim_message($l);
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
//$out .= '$a->strings['.$k.'] = ';
}
@@ -93,7 +93,7 @@ function po2php_run($argv, $argc) {
if ($k!="") $out .= $arr?");\n":";\n";
$arr=False;
$k = str_replace("msgid ","",$l);
- $k = trim($k,"\"\r\n");
+ $k = trim_message($k);
$k = $ctx.$k;
// echo $ctx ? $ctx."\nX\n":"";
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
@@ -102,14 +102,14 @@ function po2php_run($argv, $argc) {
}
if ($inv && substr($l,0,6)!="msgstr" && substr($l,0,7)!="msgctxt") {
- $v .= trim($l,"\"\r\n");
+ $v .= trim_message($l);
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
//$out .= '$a->strings['.$k.'] = ';
}
if (substr($l,0,7)=="msgctxt") {
$ctx = str_replace("msgctxt ","",$l);
- $ctx = trim($ctx,"\"\r\n");
+ $ctx = trim_message($ctx);
$ctx = "__ctx:".$ctx."__ ";
$ctx = preg_replace_callback($escape_s_exp,'escape_s',$ctx);
}
@@ -123,6 +123,14 @@ function po2php_run($argv, $argc) {
}
+function trim_message($str) {
+ // Almost same as trim("\"\r\n") except that escaped quotes are preserved
+ $str = trim($str, "\r\n");
+ $str = ltrim($str, "\"");
+ $str = preg_replace('/(?<!\\\)"+$/', '', $str);
+ return $str;
+}
+
if (array_search(__file__,get_included_files())===0){
po2php_run($argv,$argc);
}