POT file updates.

This commit is contained in:
Steve 2016-02-29 15:01:11 +00:00
parent 8242dbf037
commit a7d3c811ba
2 changed files with 211 additions and 392 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,23 +3,22 @@
<?php <?php
$strings = []; $strings = [];
$lineNumbers = [];
function addString($in) function addString($string)
{ {
global $strings; global $strings;
if ($in != "") if ($string != "")
{ {
$strings[] = $in; if (!in_array($string, $strings))
$strings = array_unique($strings); {
$strings[] = $string;
}
} }
} }
function extractC($filename) function extractC($filename)
{ {
global $lineNumbers;
$i = 0; $i = 0;
$lines = file($filename); $lines = file($filename);
@ -33,16 +32,12 @@ function extractC($filename)
if (preg_match($reg, $line, $matches) > 0) if (preg_match($reg, $line, $matches) > 0)
{ {
addString($matches[1]); addString($matches[1]);
$lineNumbers[] = "$filename:$i";
} }
} }
} }
function extractJSON($filename) function extractJSON($filename)
{ {
global $lineNumbers;
$data = file_get_contents($filename); $data = file_get_contents($filename);
$json = json_decode($data); $json = json_decode($data);
@ -50,9 +45,10 @@ function extractJSON($filename)
{ {
foreach ($json as $widget) foreach ($json as $widget)
{ {
addString($widget->{"text"}); if (array_key_exists("text", $widget))
{
$lineNumbers[] = "$filename"; addString($widget->{"text"}, $filename);
}
} }
} }
else if (strpos($filename, "missions") !== false) else if (strpos($filename, "missions") !== false)
@ -63,9 +59,7 @@ function extractJSON($filename)
{ {
foreach ($json->{"objectives"} as $objective) foreach ($json->{"objectives"} as $objective)
{ {
addString($json->{"description"}); addString($json->{"description"}, $filename);
$lineNumbers[] = "$filename";
} }
} }
@ -81,9 +75,7 @@ function extractJSON($filename)
$line = substr($line, $i); $line = substr($line, $i);
addString($line); addString($line, $filename);
$lineNumbers[] = "$filename";
} }
} }
} }
@ -134,7 +126,6 @@ $i = 0;
foreach ($strings as $string) foreach ($strings as $string)
{ {
fwrite($handle, "#: $lineNumbers[$i]\n");
fwrite($handle, "msgid \"$string\"\n"); fwrite($handle, "msgid \"$string\"\n");
fwrite($handle, "msgstr \"\"\n"); fwrite($handle, "msgstr \"\"\n");
fwrite($handle, "\n"); fwrite($handle, "\n");