Vidalia  0.3.1
Macros | Functions
ts2po.cpp File Reference
#include <QFile>
#include <QFileInfo>
#include <QDomDocument>
#include <QTextStream>
#include <QTextCodec>
#include <QDateTime>
#include <stdlib.h>
#include "ts2po_config.h"

Go to the source code of this file.

Macros

#define TS_DOCTYPE   "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_ELEMENT_LOCATION   "location"
 
#define TS_ATTR_FILENAME   "filename"
 
#define TS_ATTR_LINE   "line"
 

Functions

QString create_po_timestamp ()
 
QString create_po_header (const QString &encoding)
 
QString parse_filename (const QString &filePath)
 
int convert_context (const QDomElement &context, QString *po, QString *errorMessage)
 
int ts2po (const QDomDocument *ts, QString *po, const QString &encoding, QString *errorMessage)
 
void print_usage_and_exit ()
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

§ TS_ATTR_FILENAME

#define TS_ATTR_FILENAME   "filename"

Definition at line 28 of file ts2po.cpp.

Referenced by convert_context().

§ TS_ATTR_LINE

#define TS_ATTR_LINE   "line"

Definition at line 29 of file ts2po.cpp.

Referenced by convert_context().

§ TS_DOCTYPE

#define TS_DOCTYPE   "TS"

Definition at line 21 of file ts2po.cpp.

Referenced by ts2po().

§ TS_ELEMENT_CONTEXT

#define TS_ELEMENT_CONTEXT   "context"

Definition at line 22 of file ts2po.cpp.

Referenced by ts2po().

§ TS_ELEMENT_LOCATION

#define TS_ELEMENT_LOCATION   "location"

Definition at line 27 of file ts2po.cpp.

Referenced by convert_context().

§ TS_ELEMENT_MESSAGE

#define TS_ELEMENT_MESSAGE   "message"

Definition at line 24 of file ts2po.cpp.

Referenced by convert_context().

§ TS_ELEMENT_NAME

#define TS_ELEMENT_NAME   "name"

Definition at line 23 of file ts2po.cpp.

Referenced by convert_context().

§ TS_ELEMENT_SOURCE

#define TS_ELEMENT_SOURCE   "source"

Definition at line 25 of file ts2po.cpp.

Referenced by convert_context().

§ TS_ELEMENT_TRANSLATION

#define TS_ELEMENT_TRANSLATION   "translation"

Definition at line 26 of file ts2po.cpp.

Referenced by convert_context().

Function Documentation

§ convert_context()

int convert_context ( const QDomElement &  context,
QString *  po,
QString *  errorMessage 
)

Convert the messages in context to PO format. The output will be appended to po. Returns the number of source messages converted on success, or -1 on error and errorMessage will be set.

Definition at line 80 of file ts2po.cpp.

References parse_filename(), TS_ATTR_FILENAME, TS_ATTR_LINE, TS_ELEMENT_LOCATION, TS_ELEMENT_MESSAGE, TS_ELEMENT_NAME, TS_ELEMENT_SOURCE, and TS_ELEMENT_TRANSLATION.

Referenced by ts2po().

§ create_po_header()

QString create_po_header ( const QString &  encoding)

Return a header to be placed at the top of the .po file. The header will include encoding in the Content-Type header line.

Definition at line 43 of file ts2po.cpp.

References create_po_timestamp(), TS2PO_CONTACT_ADDR, TS2PO_LANGUAGE_TEAM, TS2PO_PROJECT_ID, and TS2PO_VERSION.

Referenced by ts2po().

§ create_po_timestamp()

QString create_po_timestamp ( )

Return the current time (in UTC) in the format YYYY-MM-DD HH:MM+0000.

Definition at line 34 of file ts2po.cpp.

Referenced by create_po_header().

§ main()

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

Definition at line 199 of file ts2po.cpp.

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

§ parse_filename()

QString parse_filename ( const QString &  filePath)

Parse the filename from the relative or absolute path given in filePath.

Definition at line 70 of file ts2po.cpp.

Referenced by convert_context().

§ print_usage_and_exit()

void print_usage_and_exit ( )

Display application usage and exit.

Definition at line 185 of file ts2po.cpp.

References tc::error().

Referenced by main().

§ ts2po()

int ts2po ( const QDomDocument *  ts,
QString *  po,
const QString &  encoding,
QString *  errorMessage 
)

Convert the TS-formatted document in ts to a PO-formatted document. The output will be written to po, including a file header that specifies encoding as the character set. Returns the number of strings converted on success, or -1 on error and errorMessage will be set.

Definition at line 144 of file ts2po.cpp.

References convert_context(), create_po_header(), TS_DOCTYPE, and TS_ELEMENT_CONTEXT.

Referenced by main().