summaryrefslogtreecommitdiff
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-05-17 16:40:14 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-21 14:32:11 +0200
commit9fa2325ab718b1d804cd1af4b282cab6deba6b56 (patch)
tree3449448eac830c71726df44247583f53656afed5 /src/script/api/qscriptengine.cpp
parent8796a2ce06fc12e9d190f9d109a92d8dfcc964cd (diff)
downloadqtscript-9fa2325ab718b1d804cd1af4b282cab6deba6b56.tar.gz
Deprecate the Encoding argument of qsTranslate
This is the same as change 4822a821facbbf834c6aab5a8a7da2b3e43f09f7 in qtdeclarative. We always assume the js source code is Utf8 encoded, as also on the C++ side. Change-Id: I4f49484241718dfc4a2bb39a674b54df46aa8c8d Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index efb19f4..8002454 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -800,10 +800,23 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): second argument (text) must be a string");
if ((args.size() > 2) && !args.at(2).isString())
return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (comment) must be a string");
- if ((args.size() > 3) && !args.at(3).isString())
- return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): fourth argument (encoding) must be a string");
- if ((args.size() > 4) && !args.at(4).isNumber())
- return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): fifth argument (n) must be a number");
+
+ int n = -1;
+ if ((args.size() > 3)) {
+ if (args.at(3).isString()) {
+ qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated");
+ if (args.size() > 4) {
+ if (args.at(4).isNumber())
+ n = args.at(4).toInt32(exec);
+ else
+ return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): fifth argument (n) must be a number");
+ }
+ } else if (args.at(3).isNumber()) {
+ n = args.at(3).toInt32(exec);
+ } else {
+ return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): fourth argument (n) must be a number");
+ }
+ }
#ifndef QT_NO_QOBJECT
JSC::UString context = args.at(0).toString(exec);
#endif
@@ -812,26 +825,13 @@ JSC::JSValue JSC_HOST_CALL functionQsTranslate(JSC::ExecState *exec, JSC::JSObje
JSC::UString comment;
if (args.size() > 2)
comment = args.at(2).toString(exec);
- QCoreApplication::Encoding encoding = QCoreApplication::UnicodeUTF8;
- if (args.size() > 3) {
- JSC::UString encStr = args.at(3).toString(exec);
- if (encStr == "CodecForTr")
- encoding = QCoreApplication::DefaultCodec;
- else if (encStr == "UnicodeUTF8")
- encoding = QCoreApplication::UnicodeUTF8;
- else
- return JSC::throwError(exec, JSC::GeneralError, QString::fromLatin1("qsTranslate(): invalid encoding '%0'").arg(encStr));
- }
- int n = -1;
- if (args.size() > 4)
- n = args.at(4).toInt32(exec);
#endif
JSC::UString result;
#ifndef QT_NO_QOBJECT
result = QCoreApplication::translate(context.UTF8String().c_str(),
text.UTF8String().c_str(),
comment.UTF8String().c_str(),
- encoding, n);
+ n);
#else
result = text;
#endif
@@ -886,7 +886,7 @@ JSC::JSValue JSC_HOST_CALL functionQsTr(JSC::ExecState *exec, JSC::JSObject*, JS
result = QCoreApplication::translate(context.UTF8String().c_str(),
text.UTF8String().c_str(),
comment.UTF8String().c_str(),
- QCoreApplication::UnicodeUTF8, n);
+ n);
#else
result = text;
#endif