~jackweirdy/vidalia/680192

« back to all changes in this revision

Viewing changes to src/tools/po2ts/po2ts.cpp

  • Committer: Package Import Robot
  • Author(s): Ulises Vitulli, intrigeri, Ulises Vitulli
  • Date: 2012-06-22 07:18:44 UTC
  • mfrom: (1.4.8) (8.2.13 sid)
  • Revision ID: package-import@ubuntu.com-20120622071844-s278v0p646pqt949
Tags: 0.2.19-1
[ intrigeri ]
* Imported Upstream version 0.2.19
* Install AppArmor profile.
* Enable hardening flags.

[ Ulises Vitulli ]
* Added runtime dependency on apparmor.
* Updated d/NEWS and d/README.Debian to reflect new features.
* Move dirs from d/rules to d/vidalia.dir.
* Updated Standard-version to 3.9.3 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
**  LICENSE file, found in the top level directory of this distribution. If you
4
4
**  did not receive the LICENSE file with this file, you may obtain it from the
5
5
**  Vidalia source package distributed by the Vidalia Project at
6
 
**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
7
 
**  including this file, may be copied, modified, propagated, or distributed 
 
6
**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
 
7
**  including this file, may be copied, modified, propagated, or distributed
8
8
**  except according to the terms described in the LICENSE file.
9
9
*/
10
10
 
31
31
new_context_element(QDomDocument *ts, const QString &contextName)
32
32
{
33
33
  QDomElement context, name;
34
 
 
 
34
 
35
35
  /* Create a <name> element */
36
36
  name = ts->createElement(TS_ELEMENT_NAME);
37
37
  name.appendChild(ts->createTextNode(contextName));
76
76
new_ts_document()
77
77
{
78
78
  QDomDocument ts(TS_DOCTYPE);
79
 
  
 
79
 
80
80
  QDomElement root = ts.createElement(TS_ELEMENT_ROOT);
81
81
  root.setAttribute(TS_ATTR_VERSION, "1.1");
82
82
  ts.appendChild(root);
110
110
QString
111
111
parse_message_string(const QString &msg)
112
112
{
113
 
  QString out = msg.trimmed(); 
114
 
  
 
113
  QString out = msg.trimmed();
 
114
 
115
115
  out.replace("\"\n\"", "");
116
116
  if (out.startsWith("\""))
117
117
    out = out.remove(0, 1);
129
129
  return stream->readLine().append("\n");
130
130
}
131
131
 
132
 
/** Skip past the header portion of the PO file and any leading whitespace. 
 
132
/** Skip past the header portion of the PO file and any leading whitespace.
133
133
 * The next line read from <b>po</b> will be the first non-header line in the
134
134
 * document. */
135
135
void
162
162
  Q_ASSERT(errorMessage);
163
163
 
164
164
  *ts = new_ts_document();
165
 
  
 
165
 
166
166
  skip_po_header(po);
167
167
  line = read_next_line(po);
168
168
  while (!po->atEnd()) {
178
178
 
179
179
    /* A context specified on a "msgctxt" line takes precedence over a context
180
180
     * specified using the overload "#:" notation. */
181
 
    if (line.startsWith("msgctxt ")) {    
 
181
    if (line.startsWith("msgctxt ")) {
182
182
      msgctxt = line.section(" ", 1);
183
183
      msgctxt = parse_message_context(msgctxt);
184
184
      line = read_next_line(po);
185
185
    }
186
 
    
 
186
 
187
187
    /* Parse the (possibly multiline) message source string */
188
188
    if (!line.startsWith("msgid ")) {
189
189
      *errorMessage = "expected 'msgid' line";
190
190
      return -1;
191
191
    }
192
192
    msgid = line.section(" ", 1);
193
 
    
 
193
 
194
194
    line = read_next_line(po);
195
195
    while (line.startsWith("\"")) {
196
196
      msgid.append(line);
204
204
      return -1;
205
205
    }
206
206
    msgstr = line.section(" ", 1);
207
 
    
 
207
 
208
208
    line = read_next_line(po);
209
209
    while (line.startsWith("\"")) {
210
210
      msgstr.append(line);
220
220
      ts->documentElement().appendChild(contextElement);
221
221
      contextElements.insert(msgctxt, contextElement);
222
222
    }
223
 
    contextElement.appendChild(new_message_element(ts, msgid, msgstr)); 
224
 
    
 
223
    contextElement.appendChild(new_message_element(ts, msgid, msgstr));
 
224
 
225
225
    n_strings++;
226
226
  }
227
227
  return n_strings;
269
269
        return 1;
270
270
      }
271
271
    } else
272
 
      print_usage_and_exit(); 
 
272
      print_usage_and_exit();
273
273
  }
274
274
 
275
275
  /* Open the input PO file for reading. */