encoding fixes for the i18n*() functions:
- take the arguments as utf8 for the ki18n* calls - don't return a utf8 byte array, but just a plain string (should avoid implicit conversion back and forth to another encoding) svn path=/trunk/KDE/kdebase/workspace/plasma/scriptengines/javascript/; revision=962285
This commit is contained in:
parent
0a0b73ad8b
commit
da4ea3dbe7
@ -518,14 +518,14 @@ QScriptValue SimpleJavaScriptApplet::jsi18n(QScriptContext *context, QScriptEngi
|
|||||||
return context->throwError(i18n("i18n takes at least one argument"));
|
return context->throwError(i18n("i18n takes at least one argument"));
|
||||||
}
|
}
|
||||||
|
|
||||||
KLocalizedString message = ki18n(context->argument(0).toString().toLocal8Bit());
|
KLocalizedString message = ki18n(context->argument(0).toString().toUtf8());
|
||||||
|
|
||||||
int numArgs = context->argumentCount();
|
int numArgs = context->argumentCount();
|
||||||
for (int i = 1; i < numArgs; ++i) {
|
for (int i = 1; i < numArgs; ++i) {
|
||||||
message.subs(context->argument(i).toString());
|
message.subs(context->argument(i).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return engine->newVariant(message.toString().toLocal8Bit());
|
return engine->newVariant(message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue SimpleJavaScriptApplet::jsi18nc(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue SimpleJavaScriptApplet::jsi18nc(QScriptContext *context, QScriptEngine *engine)
|
||||||
@ -534,15 +534,15 @@ QScriptValue SimpleJavaScriptApplet::jsi18nc(QScriptContext *context, QScriptEng
|
|||||||
return context->throwError(i18n("i18n takes at least two arguments"));
|
return context->throwError(i18n("i18n takes at least two arguments"));
|
||||||
}
|
}
|
||||||
|
|
||||||
KLocalizedString message = ki18nc(context->argument(0).toString().toLocal8Bit(),
|
KLocalizedString message = ki18nc(context->argument(0).toString().toUtf8(),
|
||||||
context->argument(1).toString().toLocal8Bit());
|
context->argument(1).toString().toUtf8());
|
||||||
|
|
||||||
int numArgs = context->argumentCount();
|
int numArgs = context->argumentCount();
|
||||||
for (int i = 2; i < numArgs; ++i) {
|
for (int i = 2; i < numArgs; ++i) {
|
||||||
message.subs(context->argument(i).toString());
|
message.subs(context->argument(i).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return engine->newVariant(message.toString().toLocal8Bit());
|
return engine->newVariant(message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue SimpleJavaScriptApplet::jsi18np(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue SimpleJavaScriptApplet::jsi18np(QScriptContext *context, QScriptEngine *engine)
|
||||||
@ -551,15 +551,15 @@ QScriptValue SimpleJavaScriptApplet::jsi18np(QScriptContext *context, QScriptEng
|
|||||||
return context->throwError(i18n("i18n takes at least two arguments"));
|
return context->throwError(i18n("i18n takes at least two arguments"));
|
||||||
}
|
}
|
||||||
|
|
||||||
KLocalizedString message = ki18np(context->argument(0).toString().toLocal8Bit(),
|
KLocalizedString message = ki18np(context->argument(0).toString().toUtf8(),
|
||||||
context->argument(1).toString().toLocal8Bit());
|
context->argument(1).toString().toUtf8());
|
||||||
|
|
||||||
int numArgs = context->argumentCount();
|
int numArgs = context->argumentCount();
|
||||||
for (int i = 2; i < numArgs; ++i) {
|
for (int i = 2; i < numArgs; ++i) {
|
||||||
message.subs(context->argument(i).toString());
|
message.subs(context->argument(i).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return engine->newVariant(message.toString().toLocal8Bit());
|
return engine->newVariant(message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue SimpleJavaScriptApplet::jsi18ncp(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue SimpleJavaScriptApplet::jsi18ncp(QScriptContext *context, QScriptEngine *engine)
|
||||||
@ -568,16 +568,16 @@ QScriptValue SimpleJavaScriptApplet::jsi18ncp(QScriptContext *context, QScriptEn
|
|||||||
return context->throwError(i18n("i18n takes at least three arguments"));
|
return context->throwError(i18n("i18n takes at least three arguments"));
|
||||||
}
|
}
|
||||||
|
|
||||||
KLocalizedString message = ki18ncp(context->argument(0).toString().toLocal8Bit(),
|
KLocalizedString message = ki18ncp(context->argument(0).toString().toUtf8(),
|
||||||
context->argument(1).toString().toLocal8Bit(),
|
context->argument(1).toString().toUtf8(),
|
||||||
context->argument(2).toString().toLocal8Bit());
|
context->argument(2).toString().toUtf8());
|
||||||
|
|
||||||
int numArgs = context->argumentCount();
|
int numArgs = context->argumentCount();
|
||||||
for (int i = 3; i < numArgs; ++i) {
|
for (int i = 3; i < numArgs; ++i) {
|
||||||
message.subs(context->argument(i).toString());
|
message.subs(context->argument(i).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return engine->newVariant(message.toString().toLocal8Bit());
|
return engine->newVariant(message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue SimpleJavaScriptApplet::dataEngine(QScriptContext *context, QScriptEngine *engine)
|
QScriptValue SimpleJavaScriptApplet::dataEngine(QScriptContext *context, QScriptEngine *engine)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user