1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include "pingus/pingus_level.hpp"
#include "util/pathname.hpp"
#include "util/raise_exception.hpp"
void
emit_msgid(const std::string& str)
{
std::cout
<< "#: " << "filename" << ":" << "lineno\n"
<< "msgid \"" << str << "\"\n"
<< "msgstr \"\"\n" << std::endl;
}
int main(int argc, char** argv)
{
std::vector<Pathname> files;
for(int i = 1; i < argc; ++i)
{
Pathname filename(argv[i], Pathname::SYSTEM_PATH);
if (filename.has_extension(".pingus"))
{
PingusLevel plf(filename);
emit_msgid(plf.get_levelname());
emit_msgid(plf.get_description());
}
else if (filename.has_extension(".worldmap"))
{
// worldmaps don't contain translatable strings at the moment
}
else if (filename.has_extension(".story"))
{
FileReader reader = FileReader::parse(filename);
std::string tmp;
if (reader.read_string("title", tmp))
{
emit_msgid(tmp);
}
FileReader all_pages = reader.read_section("pages");
const auto& childs = all_pages.get_sections();
for(auto it = childs.begin(); it != childs.end(); ++it)
{
if (it->read_string("text", tmp))
{
emit_msgid(tmp);
}
}
}
else
{
raise_exception(std::runtime_error, "unknown file type: " << filename);
}
}
return 0;
}
/* EOF */
|