Changeset 2826 for vidalia/trunk/src
- Timestamp:
- 07/02/08 11:22:52 (5 months ago)
- Files:
-
- 1 modified
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp
r2818 r2826 94 94 } 95 95 96 /** Parse the context name from <b>str</b>, where <b>str</b> is of the 97 * form ContextName#Number. This is the format used by translate-toolkit. */ 98 QString 99 parse_message_context_lame(const QString &str) 100 { 101 if (str.contains("#")) 102 return str.section("#", 0, 0); 103 return QString(); 104 } 105 96 106 /** Parse the PO-formatted message string from <b>msg</b>. If <b>msg</b> is a 97 107 * multiline string, the extra double quotes will be replaced with newlines … … 119 129 } 120 130 131 /** Skip past the header portion of the PO file and any leading whitespace. 132 * The next line read from <b>po</b> will be the first non-header line in the 133 * document. */ 134 void 135 skip_po_header(QTextStream *po) 136 { 137 QString line; 138 /* Skip any leading whitespace before the header */ 139 po->skipWhiteSpace(); 140 /* Read to the first empty line */ 141 line = po->readLine(); 142 while (!po->atEnd() && !line.isEmpty()) 143 line = po->readLine(); 144 } 145 121 146 /** Convert <b>po</b> from the PO format to a TS-formatted XML document. 122 147 * <b>ts</b> will be set to the resulting TS document. Return the number of … … 137 162 138 163 *ts = new_ts_document(); 139 164 165 skip_po_header(po); 166 line = read_next_line(po); 140 167 while (!po->atEnd()) { 141 /* Find the start of the next translation */ 142 while (!line.startsWith("msgctxt")) 168 /* Ignore all "#" lines except "#:" */ 169 while (line.startsWith("#")) { 170 if (line.startsWith("#:")) { 171 /* Context was specified with the stupid overloaded "#:" syntax.*/ 172 msgctxt = line.section(" ", 1); 173 msgctxt = parse_message_context_lame(msgctxt); 174 } 143 175 line = read_next_line(po); 144 msgctxt = line.section(" ", 1); 145 msgctxt = parse_message_context(msgctxt); 146 176 } 177 178 /* A context specified on a "msgctxt" line takes precedence over a context 179 * specified using the overload "#:" notation. */ 180 if (line.startsWith("msgctxt ")) { 181 msgctxt = line.section(" ", 1); 182 msgctxt = parse_message_context(msgctxt); 183 line = read_next_line(po); 184 } 185 147 186 /* Parse the (possibly multiline) message source string */ 148 line = read_next_line(po);149 187 if (!line.startsWith("msgid ")) { 150 188 *errorMessage = "expected 'msgid' line";
