#include #include /////////////////////////////////////////////////////////// // // (c) Kevin Krammer // // 2001-12-08 // // automatically extracts a structure from // http://www.loc.gov/standards/iso639-2/englangn.html // // see also extractlang.README // /////////////////////////////////////////////////////////// TQString twoLangs; TQString threeLangs; void parseLanguage(TQString name, TQString three, TQString two) { int star = three.find('*'); if (star > 0) three.remove(star, 1); TQString three_1 = three; int slash = three_1.find('/'); if (slash > 0) { three_1.remove(slash, 1); three_1.insert(slash, ", "); } if (!two.contains(" ")) { twoLangs.append("\t{{\""); twoLangs.append(two); twoLangs.append("\"}, {\""); twoLangs.append(three_1); twoLangs.append("\"}, {I18N_NOOP(\""); twoLangs.append(name); twoLangs.append("\")}},\n"); } else two = ""; slash = three.find('/'); if (slash > 0) { if (two.length() == 0) two = three.mid(slash+1); three.remove(slash, three.length()); } threeLangs.append("\t{{\""); threeLangs.append(two); threeLangs.append("\"}, {\""); threeLangs.append(three); threeLangs.append("\"}, {I18N_NOOP(\""); threeLangs.append(name); threeLangs.append("\")}},\n"); } TQString parseTD(TQString& line) { TQCString cline = line.local8Bit(); uint clineLength = cline.length(); TQCString result = cline; int pos = -1; bool inTag = false; for (uint i = 0; i < clineLength; ++i) { if (cline[i] == '<') inTag = true; else if (cline[i] == '>') inTag = false; else if (!inTag) { pos++; result[pos] = cline[i]; } } TQString retVal(result); retVal = retVal.left(pos+1); return retVal.simplifyWhiteSpace(); } bool parseTR(TQString& line, TQTextIStream& in) { TQString text[4]; line = in.readLine(); if (line.isNull()) return true; uint count = 0; while (line.contains(" 3) return true; text[count] = parseTD(line); count++; line = in.readLine(); } if (count == 4) { parseLanguage(text[0], text[2], text[3]); } if (line.contains("/tr")) return true; return false; } int main() { TQString line; bool readNext = true; TQTextIStream in(stdin); TQTextOStream out(stdout); while (!in.atEnd()) { if (readNext) line = in.readLine(); if (line.contains("