Further i18n integration updates.
This commit is contained in:
parent
58e7b9b8ea
commit
44c7e78606
File diff suppressed because it is too large
Load Diff
|
@ -144,7 +144,7 @@ static void executeNextLine(ScriptRunner *runner)
|
|||
else if (strcmp(command, "MSG_BOX") == 0)
|
||||
{
|
||||
sscanf(line, "%*s %255[^;]%*c%255[^\n]", strParam[0], strParam[1]);
|
||||
addMessageBox(strParam[0], strParam[1]);
|
||||
addMessageBox(strParam[0], _(strParam[1]));
|
||||
}
|
||||
else if (strcmp(command, "WAIT") == 0)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ extern void activateEntityGroups(char *groupName);
|
|||
extern void activateLocations(char *locations);
|
||||
void activateObjectives(char *objectives);
|
||||
extern int showingMessageBoxes(void);
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
#!/usr/bin/php
|
||||
|
||||
<?php
|
||||
|
||||
$strings = [];
|
||||
$lineNumbers = [];
|
||||
|
||||
function addString($in)
|
||||
{
|
||||
global $strings;
|
||||
|
||||
if ($in != "")
|
||||
{
|
||||
$strings[] = $in;
|
||||
$strings = array_unique($strings);
|
||||
}
|
||||
}
|
||||
|
||||
function extractC($filename)
|
||||
{
|
||||
global $lineNumbers;
|
||||
|
||||
$i = 0;
|
||||
|
||||
$lines = file($filename);
|
||||
|
||||
$reg = "(_\\(\"([^\\\"]*)\")";
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
$i++;
|
||||
|
||||
if (preg_match($reg, $line, $matches) > 0)
|
||||
{
|
||||
addString($matches[1]);
|
||||
|
||||
$lineNumbers[] = "$filename:$i";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function extractJSON($filename)
|
||||
{
|
||||
global $lineNumbers;
|
||||
|
||||
$data = file_get_contents($filename);
|
||||
$json = json_decode($data);
|
||||
|
||||
if (strpos($filename, "widget") !== false)
|
||||
{
|
||||
foreach ($json as $widget)
|
||||
{
|
||||
addString($widget->{"text"});
|
||||
|
||||
$lineNumbers[] = "$filename";
|
||||
}
|
||||
}
|
||||
else if (strpos($filename, "missions") !== false)
|
||||
{
|
||||
addString($json->{"description"});
|
||||
|
||||
if (array_key_exists("objectives", $json))
|
||||
{
|
||||
foreach ($json->{"objectives"} as $objective)
|
||||
{
|
||||
addString($json->{"description"});
|
||||
|
||||
$lineNumbers[] = "$filename";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("script", $json))
|
||||
{
|
||||
foreach ($json->{"script"} as $scripts)
|
||||
{
|
||||
foreach ($scripts->{"lines"} as $line)
|
||||
{
|
||||
if (strpos($line, "MSG_BOX") === 0)
|
||||
{
|
||||
$i = strpos($line, ";") + 1;
|
||||
|
||||
$line = substr($line, $i);
|
||||
|
||||
addString($line);
|
||||
|
||||
$lineNumbers[] = "$filename";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function recurseDir($dir)
|
||||
{
|
||||
$files = array_diff(scandir($dir), array('..', '.'));
|
||||
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (is_dir("$dir/$file"))
|
||||
{
|
||||
recurseDir("$dir/$file");
|
||||
}
|
||||
else if (strstr($file, ".c") !== FALSE)
|
||||
{
|
||||
extractC("$dir/$file");
|
||||
}
|
||||
else if (strstr($file, ".json") !== FALSE)
|
||||
{
|
||||
extractJSON("$dir/$file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recurseDir("../src");
|
||||
|
||||
recurseDir("../data/widgets");
|
||||
|
||||
recurseDir("../data/missions");
|
||||
|
||||
recurseDir("../data/challenges");
|
||||
|
||||
$potHeader = file_get_contents("../tools/potHeader.txt");
|
||||
|
||||
$handle = fopen("../locale/tbftss.pot", "w");
|
||||
|
||||
$dateTime = date("Y-m-d H:i:sO");
|
||||
|
||||
$potHeader = str_replace("{POT_CREATION_DATE}", $dateTime, $potHeader);
|
||||
|
||||
fwrite($handle, "$potHeader\n");
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ($strings as $string)
|
||||
{
|
||||
fwrite($handle, "#: $lineNumbers[$i]\n");
|
||||
fwrite($handle, "msgid \"$string\"\n");
|
||||
fwrite($handle, "msgstr \"\"\n");
|
||||
fwrite($handle, "\n");
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
fclose($handle);
|
||||
|
||||
?>
|
|
@ -0,0 +1,17 @@
|
|||
# PO file for TBFTSS : The Pandoran War
|
||||
# Copyright 2015-2016, Stephen J Sweeney
|
||||
# This file is distributed under the GNU GPL 3.0
|
||||
# Email: stephenjsweeney@battleforthesolarsystem.com
|
||||
# https://github.com/stephenjsweeney/tbftss
|
||||
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: TBFTSS: The Pandoran War\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: {POT_CREATION_DATE}\n"
|
||||
"PO-Revision-Date: ???\n"
|
||||
"Last-Translator: ???\n"
|
||||
"Language-Team: ???\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
Loading…
Reference in New Issue