Changeset 2818 for vidalia/trunk/src
- Timestamp:
- 07/02/08 01:17:18 (5 months ago)
- Files:
-
- 1 modified
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vidalia/trunk/src/tools/po2ts/po2ts.cpp
r2813 r2818 85 85 86 86 /** Parse the context name from <b>str</b>, where the context name is of the 87 * form ContextName#Number. This is the format used by translate-toolkit. */87 * form DQUOTE ContextName DQUOTE. */ 88 88 QString 89 parse_ context_name(const QString &str)90 { 91 if (str.contains("#"))92 return str.section("#", 0, 0);93 return QString();89 parse_message_context(const QString &str) 90 { 91 QString out = str.trimmed(); 92 out = out.replace("\"", ""); 93 return out; 94 94 } 95 95 … … 126 126 po2ts(QTextStream *po, QDomDocument *ts, QString *errorMessage) 127 127 { 128 QString line, context, msgid, msgstr; 128 QString line; 129 QString msgctxt, msgid, msgstr; 129 130 QHash<QString,QDomElement> contextElements; 130 131 QDomElement contextElement, msgElement, transElement; … … 138 139 139 140 while (!po->atEnd()) { 140 /* Parse the context name and ignore other "#" lines.*/141 if (!line.startsWith("#: ")) {141 /* Find the start of the next translation */ 142 while (!line.startsWith("msgctxt")) 142 143 line = read_next_line(po); 143 continue; 144 } 145 context = parse_context_name(line.section(" ", 1)); 146 while (line.startsWith("#")) 147 line = read_next_line(po); 144 msgctxt = line.section(" ", 1); 145 msgctxt = parse_message_context(msgctxt); 148 146 149 147 /* Parse the (possibly multiline) message source string */ 148 line = read_next_line(po); 150 149 if (!line.startsWith("msgid ")) { 151 150 *errorMessage = "expected 'msgid' line"; … … 176 175 177 176 /* Add the message and translation to the .ts document */ 178 if (contextElements.contains( context)) {179 contextElement = contextElements.value( context);177 if (contextElements.contains(msgctxt)) { 178 contextElement = contextElements.value(msgctxt); 180 179 } else { 181 contextElement = new_context_element(ts, context);180 contextElement = new_context_element(ts, msgctxt); 182 181 ts->documentElement().appendChild(contextElement); 183 contextElements.insert( context, contextElement);182 contextElements.insert(msgctxt, contextElement); 184 183 } 185 184 contextElement.appendChild(new_message_element(ts, msgid, msgstr));
