summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-12-09 01:31:46 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-12-09 01:31:46 (GMT)
commitbf50114e0a039102b37f7f7a50def33b2275b3b3 (patch)
treef0b8a3695cee8bf255de08909e8f5fa211b5de98
parent31156004ac128a3d35870e3cc8b198515fa7b4d9 (diff)
parent81e855944cecbd0a37bd04c899d71add97a15a65 (diff)
downloadQt-bf50114e0a039102b37f7f7a50def33b2275b3b3.zip
Qt-bf50114e0a039102b37f7f7a50def33b2275b3b3.tar.gz
Qt-bf50114e0a039102b37f7f7a50def33b2275b3b3.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/qmli18n.qdoc29
-rw-r--r--src/script/api/qscriptengine.cpp7
2 files changed, 33 insertions, 3 deletions
diff --git a/doc/src/declarative/qmli18n.qdoc b/doc/src/declarative/qmli18n.qdoc
index 4b62fcb..0c8b1d1 100644
--- a/doc/src/declarative/qmli18n.qdoc
+++ b/doc/src/declarative/qmli18n.qdoc
@@ -43,6 +43,8 @@
\page qmli18n.html
\title QML Internationalization
+\section1 Overview
+
Strings in QML can be marked for translation using the qsTr(), qsTranslate(),
QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions.
@@ -63,4 +65,31 @@ capabilities are described more fully in:
You can test a translation in \l {qmlviewer} using the -translation option.
+\section1 Example
+
+First we create a simple QML file with text to be translated. The string
+that needs to be translated is enclosed in a call to \c qsTr().
+
+hello.qml:
+\qml
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Text { text: qsTr("Hello"); anchors.centerIn: parent }
+}
+\endqml
+
+Next we create a translation source file using lupdate:
+\code
+lupdate hello.qml -ts hello.ts
+\endcode
+
+Then we open \c hello.ts in \l {Linguist}, provide a translation
+and create the release file \c hello.qm.
+
+Finally, we can test the translation in qmlviewer:
+\code
+qmlviewer -translation hello.qm hello.qml
+\endcode
*/
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index b6aa872..1879367 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -33,6 +33,7 @@
#include "qscriptvalue_p.h"
#include "qscriptvalueiterator.h"
#include "qscriptclass.h"
+#include "qscriptcontextinfo.h"
#include "qscriptprogram.h"
#include "qscriptprogram_p.h"
#include "qdebug.h"
@@ -698,9 +699,9 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
#ifndef QT_NO_QOBJECT
QString context;
-// ### implement context resolution
-// if (ctx->parentContext())
-// context = QFileInfo(ctx->parentContext()->fileName()).baseName();
+ QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec);
+ if (ctx && ctx->parentContext())
+ context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName();
#endif
QString text(args.at(0).toString(exec));
#ifndef QT_NO_QOBJECT