#!/usr/bin/php 0) { addString($matches[1]); } } } function extractJSON($filename) { $data = file_get_contents($filename); $json = json_decode($data); if (strpos($filename, "widget") !== false) { foreach ($json as $widget) { if (array_key_exists("text", $widget)) { addString($widget->{"text"}, $filename); } } } else if (strpos($filename, "trophies") !== false) { foreach ($json as $trophy) { addString($trophy->{"title"}); addString($trophy->{"description"}); } } else if (strpos($filename, "maps") !== false) { if (array_key_exists("entities", $json)) { foreach ($json->{"entities"} as $entity) { if ($entity->{"type"} == "InfoPoint") { addString($entity->{"message"}); } } } if (array_key_exists("objectives", $json)) { foreach ($json->{"objectives"} as $objective) { addString($objective->{"description"}); } } } else if (strpos($filename, "missions") !== false) { if (array_key_exists("missions", $json)) { foreach ($json->{"missions"} as $missions) { addString($missions->{"description"}); } } } } function extractText($filename) { $lines = file($filename, FILE_IGNORE_NEW_LINES); foreach ($lines as $line) { addString($line); } } 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"); } else if (strstr($file, "ending.txt") !== FALSE) { extractText("$dir/$file"); } } } recurseDir("../src"); recurseDir("../data/widgets"); recurseDir("../data/maps"); recurseDir("../data/misc"); recurseDir("../data/hub"); $potHeader = file_get_contents("../tools/potHeader.txt"); $handle = fopen("../locale/blobwarsAttrition.pot", "w"); $dateTime = date("Y-m-d H:i:sO"); $potHeader = str_replace("{POT_CREATION_DATE}", $dateTime, $potHeader); fwrite($handle, "$potHeader\n"); foreach ($strings as $string) { fwrite($handle, "msgid \"$string\"\n"); fwrite($handle, "msgstr \"\"\n"); fwrite($handle, "\n"); } fclose($handle); ?>