Commit 1a14ed21 by Sorokin Victor

Update MessageController.php

parent 4d4a3f08
...@@ -283,7 +283,7 @@ class MessageController extends Controller ...@@ -283,7 +283,7 @@ class MessageController extends Controller
{ {
echo "Saving messages to $fileName..."; echo "Saving messages to $fileName...";
if (is_file($fileName)) { if (is_file($fileName)) {
if($format === 'po'){ if ($format === 'po') {
$translated = file_get_contents($fileName); $translated = file_get_contents($fileName);
preg_match_all('/(?<=msgid ").*(?="\n(#*)msgstr)/', $translated, $keys); preg_match_all('/(?<=msgid ").*(?="\n(#*)msgstr)/', $translated, $keys);
preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values); preg_match_all('/(?<=msgstr ").*(?="\n\n)/', $translated, $values);
...@@ -300,7 +300,7 @@ class MessageController extends Controller ...@@ -300,7 +300,7 @@ class MessageController extends Controller
$merged = []; $merged = [];
$untranslated = []; $untranslated = [];
foreach ($messages as $message) { foreach ($messages as $message) {
if($format === 'po'){ if ($format === 'po') {
$message = preg_replace('/\"/', '\"', $message); $message = preg_replace('/\"/', '\"', $message);
} }
if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) { if (array_key_exists($message, $translated) && strlen($translated[$message]) > 0) {
...@@ -332,9 +332,9 @@ class MessageController extends Controller ...@@ -332,9 +332,9 @@ class MessageController extends Controller
if (false === $overwrite) { if (false === $overwrite) {
$fileName .= '.merged'; $fileName .= '.merged';
} }
if ($format === 'po'){ if ($format === 'po') {
$output = ''; $output = '';
foreach ($merged as $k => $v){ foreach ($merged as $k => $v) {
$k = preg_replace('/(\")|(\\\")/', "\\\"", $k); $k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$v = preg_replace('/(\")|(\\\")/', "\\\"", $v); $v = preg_replace('/(\")|(\\\")/', "\\\"", $v);
if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') { if (substr($v, 0, 2) === '@@' && substr($v, -2) === '@@') {
...@@ -353,7 +353,7 @@ class MessageController extends Controller ...@@ -353,7 +353,7 @@ class MessageController extends Controller
if ($format === 'po') { if ($format === 'po') {
$merged = ''; $merged = '';
sort($messages); sort($messages);
foreach($messages as $message) { foreach ($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message); $message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n"; $merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n"; $merged .= "msgstr \"\"\n";
......
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