po2ts.cpp File Reference

#include <QHash>
#include <QFile>
#include <QDomDocument>
#include <QTextStream>
#include <QTextCodec>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define TS_DOCTYPE   "TS"
#define TS_ELEMENT_ROOT   "TS"
#define TS_ELEMENT_CONTEXT   "context"
#define TS_ELEMENT_NAME   "name"
#define TS_ELEMENT_MESSAGE   "message"
#define TS_ELEMENT_SOURCE   "source"
#define TS_ELEMENT_TRANSLATION   "translation"
#define TS_ATTR_TRANSLATION_TYPE   "type"
#define TS_ATTR_VERSION   "version"

Functions

QDomElement new_context_element (QDomDocument *ts, const QString &contextName)
QDomElement new_message_element (QDomDocument *ts, const QString &msgid, const QString &msgstr)
QDomDocument new_ts_document ()
QString parse_message_context (const QString &str)
QString parse_message_context_lame (const QString &str)
QString parse_message_string (const QString &msg)
QString read_next_line (QTextStream *stream)
void skip_po_header (QTextStream *po)
int po2ts (QTextStream *po, QDomDocument *ts, QString *errorMessage)
void print_usage_and_exit ()
int main (int argc, char *argv[])


Define Documentation

#define TS_ATTR_TRANSLATION_TYPE   "type"

Definition at line 25 of file po2ts.cpp.

Referenced by new_message_element().

#define TS_ATTR_VERSION   "version"

Definition at line 26 of file po2ts.cpp.

Referenced by new_ts_document().

#define TS_DOCTYPE   "TS"

Definition at line 18 of file po2ts.cpp.

Referenced by new_ts_document(), and ts2po().

#define TS_ELEMENT_CONTEXT   "context"

Definition at line 20 of file po2ts.cpp.

Referenced by new_context_element(), and ts2po().

#define TS_ELEMENT_MESSAGE   "message"

Definition at line 22 of file po2ts.cpp.

Referenced by convert_context(), and new_message_element().

#define TS_ELEMENT_NAME   "name"

Definition at line 21 of file po2ts.cpp.

Referenced by convert_context(), and new_context_element().

#define TS_ELEMENT_ROOT   "TS"

Definition at line 19 of file po2ts.cpp.

Referenced by new_ts_document().

#define TS_ELEMENT_SOURCE   "source"

Definition at line 23 of file po2ts.cpp.

Referenced by convert_context(), and new_message_element().

#define TS_ELEMENT_TRANSLATION   "translation"

Definition at line 24 of file po2ts.cpp.

Referenced by convert_context(), and new_message_element().


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 246 of file po2ts.cpp.

References tc::error(), i(), po2ts(), and print_usage_and_exit().

QDomElement new_context_element ( QDomDocument *  ts,
const QString &  contextName 
)

Create a new context element with the name contextName.

Definition at line 31 of file po2ts.cpp.

References TS_ELEMENT_CONTEXT, and TS_ELEMENT_NAME.

Referenced by po2ts().

QDomElement new_message_element ( QDomDocument *  ts,
const QString &  msgid,
const QString &  msgstr 
)

Create a new message element using the source string msgid and the translation msgstr.

Definition at line 48 of file po2ts.cpp.

References TS_ATTR_TRANSLATION_TYPE, TS_ELEMENT_MESSAGE, TS_ELEMENT_SOURCE, and TS_ELEMENT_TRANSLATION.

Referenced by po2ts(), and po2wxl().

QDomDocument new_ts_document (  ) 

Create a new TS document of the appropriate doctype and with a TS root element.

Definition at line 76 of file po2ts.cpp.

References TS_ATTR_VERSION, TS_DOCTYPE, and TS_ELEMENT_ROOT.

Referenced by po2ts().

QString parse_message_context ( const QString &  str  ) 

Parse the context name from str, where the context name is of the form DQUOTE ContextName DQUOTE.

Definition at line 90 of file po2ts.cpp.

QString parse_message_context_lame ( const QString &  str  ) 

Parse the context name from str, where str is of the form ContextName::Number. This is the format used by translate-toolkit.

Definition at line 100 of file po2ts.cpp.

QString parse_message_string ( const QString &  msg  ) 

Parse the PO-formatted message string from msg. If msg is a multiline string, the extra double quotes will be replaced with newlines appropriately.

Definition at line 111 of file po2ts.cpp.

int po2ts ( QTextStream *  po,
QDomDocument *  ts,
QString *  errorMessage 
)

Convert po from the PO format to a TS-formatted XML document. ts will be set to the resulting TS document. Return the number of converted strings on success, or -1 on error and errorMessage will be set.

Definition at line 152 of file po2ts.cpp.

References new_context_element(), new_message_element(), new_ts_document(), parse_message_context(), parse_message_context_lame(), parse_message_string(), read_next_line(), and skip_po_header().

Referenced by main().

void print_usage_and_exit (  ) 

Display application usage and exit.

Definition at line 232 of file po2ts.cpp.

References tc::error().

QString read_next_line ( QTextStream *  stream  ) 

Read and return the next non-empty line from stream.

Definition at line 126 of file po2ts.cpp.

void skip_po_header ( QTextStream *  po  ) 

Skip past the header portion of the PO file and any leading whitespace. The next line read from po will be the first non-header line in the document.

Definition at line 136 of file po2ts.cpp.


Generated on Mon Aug 30 19:14:03 2010 for Vidalia by  doxygen 1.5.9