Vidalia  0.3.1
Macros | Functions
po2wxl.cpp File Reference
#include <QFile>
#include <QDomDocument>
#include <QTextStream>
#include <QTextCodec>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define WXL_NAMESPACE   "http://schemas.microsoft.com/wix/2006/localization"
 
#define WXL_ELEMENT_ROOT   "WixLocalization"
 
#define WXL_ELEMENT_MESSAGE   "String"
 
#define WXL_ATTR_MESSAGE_ID   "Id"
 
#define WXL_ATTR_LANGUAGE   "LCID"
 
#define WXL_ATTR_TRANSLATION_TYPE   "Culture"
 
#define WXL_ATTR_OVERRIDABLE   "Overridable"
 

Functions

QString culture_lcid (const QString &culture)
 
QDomElement new_message_element (QDomDocument *wxl, const QString &strid, const QString &msgid, const QString &msgstr)
 
QDomDocument new_wxl_document (const QString &culture)
 
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 po2wxl (const QString &culture, QTextStream *po, QDomDocument *wxl, QString *errorMessage)
 
void print_usage_and_exit ()
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

◆ WXL_ATTR_LANGUAGE

#define WXL_ATTR_LANGUAGE   "LCID"

Definition at line 23 of file po2wxl.cpp.

◆ WXL_ATTR_MESSAGE_ID

#define WXL_ATTR_MESSAGE_ID   "Id"

Definition at line 22 of file po2wxl.cpp.

◆ WXL_ATTR_OVERRIDABLE

#define WXL_ATTR_OVERRIDABLE   "Overridable"

Definition at line 25 of file po2wxl.cpp.

◆ WXL_ATTR_TRANSLATION_TYPE

#define WXL_ATTR_TRANSLATION_TYPE   "Culture"

Definition at line 24 of file po2wxl.cpp.

◆ WXL_ELEMENT_MESSAGE

#define WXL_ELEMENT_MESSAGE   "String"

Definition at line 21 of file po2wxl.cpp.

◆ WXL_ELEMENT_ROOT

#define WXL_ELEMENT_ROOT   "WixLocalization"

Definition at line 20 of file po2wxl.cpp.

◆ WXL_NAMESPACE

#define WXL_NAMESPACE   "http://schemas.microsoft.com/wix/2006/localization"

Definition at line 19 of file po2wxl.cpp.

Function Documentation

◆ culture_lcid()

QString culture_lcid ( const QString &  culture)

We need to provide an element with the LCID for this locale that is used in the WiX Product definition.

Definition at line 30 of file po2wxl.cpp.

Referenced by po2wxl().

◆ main()

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

Definition at line 271 of file po2wxl.cpp.

References tc::DebugMessage::arg(), tc::error(), i(), po2wxl(), and print_usage_and_exit().

◆ new_message_element()

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

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

Definition at line 70 of file po2wxl.cpp.

References WXL_ATTR_MESSAGE_ID, WXL_ATTR_OVERRIDABLE, and WXL_ELEMENT_MESSAGE.

Referenced by po2wxl().

◆ new_wxl_document()

QDomDocument new_wxl_document ( const QString &  culture)

Create a new WXL document of the appropriate doctype and root element with the Microsoft style culture name for locale.

Definition at line 93 of file po2wxl.cpp.

References WXL_ATTR_TRANSLATION_TYPE, WXL_ELEMENT_ROOT, and WXL_NAMESPACE.

Referenced by po2wxl().

◆ parse_message_context()

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 107 of file po2wxl.cpp.

Referenced by po2wxl().

◆ parse_message_context_lame()

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 117 of file po2wxl.cpp.

Referenced by po2wxl().

◆ parse_message_string()

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 128 of file po2wxl.cpp.

Referenced by po2wxl().

◆ po2wxl()

int po2wxl ( const QString &  culture,
QTextStream *  po,
QDomDocument *  wxl,
QString *  errorMessage 
)

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

Definition at line 177 of file po2wxl.cpp.

References culture_lcid(), new_message_element(), new_wxl_document(), parse_message_context(), parse_message_context_lame(), parse_message_string(), read_next_line(), skip_po_header(), and WXL_ATTR_LANGUAGE.

Referenced by main().

◆ print_usage_and_exit()

void print_usage_and_exit ( )

Display application usage and exit.

Definition at line 256 of file po2wxl.cpp.

References tc::error().

Referenced by main().

◆ read_next_line()

QString read_next_line ( QTextStream *  stream)

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

Definition at line 151 of file po2wxl.cpp.

Referenced by po2wxl().

◆ skip_po_header()

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 161 of file po2wxl.cpp.

Referenced by po2wxl().