Commit 08cf7e7b by SergeiKutanov

po filles generation.

All the quotation marks must be screened by adding a backslash before them. Otherwise we cannot generate .mo file.
parent e09b016a
...@@ -189,6 +189,7 @@ class MessageController extends Controller ...@@ -189,6 +189,7 @@ class MessageController extends Controller
$merged = []; $merged = [];
$untranslated = []; $untranslated = [];
foreach ($messages as $message) { foreach ($messages as $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) {
$merged[$message] = $translated[$message]; $merged[$message] = $translated[$message];
} else { } else {
...@@ -202,6 +203,7 @@ class MessageController extends Controller ...@@ -202,6 +203,7 @@ class MessageController extends Controller
$todo[$message] = ''; $todo[$message] = '';
} }
ksort($translated); ksort($translated);
if($format === 'php'){
foreach ($translated as $message => $translation) { foreach ($translated as $message => $translation) {
if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeUnused) { if (!isset($merged[$message]) && !isset($todo[$message]) && !$removeUnused) {
if (substr($translation, 0, 2) === '@@' && substr($translation, -2) === '@@') { if (substr($translation, 0, 2) === '@@' && substr($translation, -2) === '@@') {
...@@ -211,6 +213,7 @@ class MessageController extends Controller ...@@ -211,6 +213,7 @@ class MessageController extends Controller
} }
} }
} }
}
$merged = array_merge($todo, $merged); $merged = array_merge($todo, $merged);
if ($sort) { if ($sort) {
ksort($merged); ksort($merged);
...@@ -221,6 +224,8 @@ class MessageController extends Controller ...@@ -221,6 +224,8 @@ class MessageController extends Controller
if($format === 'po'){ if($format === 'po'){
$out_str = ''; $out_str = '';
foreach($merged as $k=>$v){ foreach($merged as $k=>$v){
$k = preg_replace('/(\")|(\\\")/', "\\\"", $k);
$v = preg_replace('/(\")|(\\\")/', "\\\"", $v);
$out_str .= "msgid \"$k\"\n"; $out_str .= "msgid \"$k\"\n";
$out_str .= "msgstr \"$v\"\n"; $out_str .= "msgstr \"$v\"\n";
$out_str .= "\n"; $out_str .= "\n";
...@@ -233,6 +238,7 @@ class MessageController extends Controller ...@@ -233,6 +238,7 @@ class MessageController extends Controller
$merged = ''; $merged = '';
sort($messages); sort($messages);
foreach($messages as $message) { foreach($messages as $message) {
$message = preg_replace('/(\")|(\\\")/', '\\\"', $message);
$merged .= "msgid \"$message\"\n"; $merged .= "msgid \"$message\"\n";
$merged .= "msgstr \"\"\n"; $merged .= "msgstr \"\"\n";
$merged .= "\n"; $merged .= "\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