<ar><k>Airplane</k>
Aeroplane</ar>
<ar><k>Aluminum</k>
-Aluminium</ar>
+Aluminium to text text wiecej tekstu to text text wiecej tekstuto text text wiecej tekstuto text text wiecej tekstuto text text wiecej tekstuto text text wiecej tekstuto text text wiecej tekstuto text text wiecej tekstu</ar>
<ar><k>Apartment</k>
Flatlane</ar>
<ar><k>Appetizer</k>
Tartlane</ar>
<ar><k>airplane</k>
Aeroplane</ar>
-<ar><k>aluminum</k>
-Aluminium</ar>
+<ar><k>Aluminum</k>
+Aluminium to ala ma kota a kot ma ale Aluminium to ala ma kota a kot ma alAluminium to ala ma kota a kot ma alAluminium to ala ma kota a kot ma al</ar>
<ar><k>amrtment</k>
Medium Wave</ar>
<ar><k>anesthesia</k>
#
#-------------------------------------------------
-QT += core gui
+QT += core gui xmlpatterns xml
maemo5 {
QT += maemo5
desktop.files += ../../../data/other/$${TARGET}.desktop
icon64.files += ../../../data/icons/64x64/$${TARGET}.png
}
+
+RESOURCES += xslt2.qrc
setWindowFlags(windowFlags() | Qt::Window);
initializeUI();
-
+ //Q_INIT_RESOURCE(xslt);
setWindowTitle(tr("Translation"));
}
trans += t + "\n";
}
- textEdit->setPlainText(trans);
+// qDebug()<<trans;
+ trans=tr("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>") + tr("\n <ar>") + trans + tr("\n </ar>");
+
+ trans=XslConversion(trans);
+ textEdit->insertHtml(trans);
+ // textEdit->setPlainText(trans);
textEdit->repaint(this->rect());
emit updateSize();
}
+QString TranslationWidget::XslConversion(QString translation)
+{
+ QXmlQuery myQuery(QXmlQuery::XSLT20);
+ myQuery.setFocus(translation);
+// qDebug()<<translation;
+ QFile file(":/xsl/xsl.xsl");
+ if(!file.open(QFile::ReadOnly)){
+ qDebug()<<"can't open a xslt file";
+ return translation;
+ }
+ QString xslt;
+ xslt=file.readAll();
+ myQuery.setQuery(xslt);
+ QString result("");
+ myQuery.evaluateTo(&result);
+ return result;
+}
+
void TranslationWidget::initializeUI() {
zoomInToolButton = new QToolButton;
#include <QtGui>
#include "../backbone/backbone.h"
#include "TranslationWidgetAutoResizer.h"
+#include <QtXml>
+#include <QXmlQuery>
//! Displays translation of word found in dictionaries
/*!
private:
+ QString XslConversion(QString translation);
QTextEdit *textEdit;
QToolButton* zoomInToolButton;
QToolButton* zoomOutToolButton;
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+ <html>
+ <body>
+ <table border="1" WIDTH="100%">
+ <tr bgcolor="#FF0000">
+ <th><xsl:value-of select="ar/dict[1]/key"/></th>
+ </tr>
+ <xsl:for-each select="ar/dict">
+ <tr bgcolor="#9acd32">
+ <th><xsl:value-of select="info"/></th>
+ </tr>
+ <xsl:for-each select="t">
+ <tr>
+ <td><xsl:apply-templates/></td>
+ </tr>
+ </xsl:for-each>
+ </xsl:for-each>
+ </table>
+ </body>
+ </html>
+</xsl:template>
+
+<xsl:template match="tr">
+ [<i><xsl:apply-templates/></i>]
+</xsl:template>
+
+<xsl:template match="pot">
+ ,<i><xsl:apply-templates/></i>
+</xsl:template>
+
+<xsl:template match="tence">
+ ,<i><xsl:apply-templates/></i>
+</xsl:template>
+
+<xsl:template match="def">
+ ,(<xsl:apply-templates/>)
+</xsl:template>
+
+<xsl:template match="ex">
+ ,"<xsl:apply-templates/>"
+</xsl:template>
+
+<xsl:template match="c">
+ <xsl:variable name="atr" select="@c"/>
+ <font color="{$atr}"> <xsl:apply-templates/> </font>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<RCC>
+ <qresource prefix="/xsl">
+ <file>xsl.xsl</file>
+ </qresource>
+</RCC>
}
QString TranslationXdxf::toHtml() const {
- return xdxfPlugin->search(_key);
+ QString result("");
+// qDebug()<<xdxfPlugin->search(_key);
+ result+="<dict>" + _dictionaryInfo + "<key>" + _key + "</key>" +xdxfPlugin->search(_key) + "</dict>";
+// qDebug()<<result;
+ return result;
}
void TranslationXdxf::setKey(QString _key) {
}
stopped=false;
dictionaryFile.close();
+
return resultString;
}
if(reader.name()=="description")
_infoNote=reader.readElementText();
+ _infoNote="<info path=\""+path+"\">"+"\n" + _name + "(" + _type + ")" + "</info>";
+
dictionaryFile.close();
}