diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-05-06 23:14:36 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-09 00:56:16 +0200 |
commit | 4822a821facbbf834c6aab5a8a7da2b3e43f09f7 (patch) | |
tree | 308ed131b2888f870e05f7b7260fe38f270c19f1 | |
parent | 2c4c7a38aa59e4b9970abd6456df99d597b3c45a (diff) |
qsTranslate shouldn't require an encoding argument
The encoding is anyway utf-8 in all case, so we can just
as well get rid of the argument. Support the old syntax
for backwards compatibility, but issue a qWarning when it's
being used.
The new syntax simply removes the encoding as 4th argument.
Change-Id: Ib34aec58997a4f026440385e8ed763ef953674d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 761676d8c5..26ecc939c3 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1190,8 +1190,6 @@ v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args) V8THROW_ERROR("qsTranslate(): second argument (text) must be a string"); if ((args.Length() > 2) && !args[2]->IsString()) V8THROW_ERROR("qsTranslate(): third argument (comment) must be a string"); - if ((args.Length() > 3) && !args[3]->IsString()) - V8THROW_ERROR("qsTranslate(): fourth argument (encoding) must be a string"); QV8Engine *v8engine = V8ENGINE(); QString context = v8engine->toString(args[0]); @@ -1199,25 +1197,20 @@ v8::Handle<v8::Value> qsTranslate(const v8::Arguments &args) QString comment; if (args.Length() > 2) comment = v8engine->toString(args[2]); - QCoreApplication::Encoding encoding = QCoreApplication::UnicodeUTF8; - if (args.Length() > 3) { - QString encStr = v8engine->toString(args[3]); - if (encStr == QLatin1String("UnicodeUTF8")) { - encoding = QCoreApplication::UnicodeUTF8; - } else { - QString msg = QString::fromLatin1("qsTranslate(): invalid encoding '%0'").arg(encStr); - V8THROW_ERROR((uint16_t *)msg.constData()); - } + int i = 3; + if (args.Length() > i && args[i]->IsString()) { + qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated"); + ++i; } int n = -1; - if (args.Length() > 4) - n = args[4]->Int32Value(); + if (args.Length() > i) + n = args[i]->Int32Value(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), - encoding, n); + QCoreApplication::UnicodeUTF8, n); return v8engine->toString(result); } |