PoEntry ReadPoEntry()
{
PoLine line;
// skip whitespace.
do {
line = ReadLine();
} while (line != null && line.kind == PoLineKind.Blank);
if (line == null)
return null; // at end of file.
List<PoLocation> locations = new List<PoLocation>();
string localized = "", nonlocalized = "";
string currentKeyword = null;
do {
if (line.kind == PoLineKind.LocationComment)
locations.Add(new PoLocation(line.str1, line.str2));
else if (line.kind == PoLineKind.KeywordString) {
currentKeyword = line.str1;
if (currentKeyword == "msgid")
nonlocalized = line.str2;
else if (currentKeyword == "msgstr")
localized = line.str2;
}
else if (line.kind == PoLineKind.String) {
if (currentKeyword == "msgid")
nonlocalized += line.str1;
else if (currentKeyword == "msgstr")
localized += line.str1;
}
line = ReadLine();
}
while (line != null && line.kind != PoLineKind.Blank);
return new PoEntry(locations, nonlocalized, localized);
}