[rkward-cvs] SF.net SVN: rkward-code:[4987] trunk/rkward/rkward
tfry at users.sf.net
tfry at users.sf.net
Mon Nov 3 19:30:58 UTC 2014
Revision: 4987
http://sourceforge.net/p/rkward/code/4987
Author: tfry
Date: 2014-11-03 19:30:57 +0000 (Mon, 03 Nov 2014)
Log Message:
-----------
Add some i18n for testing, and fix the first round of bugs.
Modified Paths:
--------------
trunk/rkward/rkward/misc/rkmessagecatalog.cpp
trunk/rkward/rkward/plugins/testing/test1.js
trunk/rkward/rkward/plugins/testing/test1.xml
trunk/rkward/rkward/scriptbackends/qtscripti18n.h
Modified: trunk/rkward/rkward/misc/rkmessagecatalog.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkmessagecatalog.cpp 2014-11-03 16:15:18 UTC (rev 4986)
+++ trunk/rkward/rkward/misc/rkmessagecatalog.cpp 2014-11-03 19:30:57 UTC (rev 4987)
@@ -56,15 +56,18 @@
QString RKMessageCatalog::translate (const QString &msgctxt, const QString &msgid_singular, const QString &msgid_plural, unsigned long int count) const {
RK_TRACE (MISC);
+ QString ret;
QByteArray key = (msgctxt + GETTEXT_CONTEXT_GLUE + msgid_singular).toUtf8 ();
QByteArray pkey = msgid_plural.toUtf8 ();
const char *trans = dngettext (catalog_name, key, pkey, count);
if ((trans == key) || (trans == pkey)) {
- if (count == 1) return msgid_singular.arg (count);
- return msgid_plural.arg (count);
+ if (count == 1) ret = msgid_singular;
+ else ret = msgid_plural;
+ } else {
+ ret = QString::fromUtf8 (trans);
}
- return QString::fromUtf8 (trans).replace (QLatin1String ("%1"), QString::number (count)); // NOTE: Not using .arg(count), as "%1" may not be given in both singular and plural form.
- // .arg() would go replacing "%2", then.
+ return ret.replace (QLatin1String ("%1"), QString::number (count)); // NOTE: Not using .arg(count), as "%1" may not be given in both singular and plural form.
+ // .arg() would go replacing "%2", then.
}
QString RKMessageCatalog::translate (const QString &msgid) const {
Modified: trunk/rkward/rkward/plugins/testing/test1.js
===================================================================
--- trunk/rkward/rkward/plugins/testing/test1.js 2014-11-03 16:15:18 UTC (rev 4986)
+++ trunk/rkward/rkward/plugins/testing/test1.js 2014-11-03 19:30:57 UTC (rev 4987)
@@ -9,7 +9,17 @@
}
function printout () {
- makeHeaderCode ("SimpleAnova", new Array ("Model", getValue ("model"), "Data", getValue ("model.table"), "Test", noquote ("print ('hi')")))
+ makeHeaderCode ("SimpleAnova", new Array (i18nc ("GLM Model specification", "Model"), getValue ("model"), "Data", getValue ("model.table"), "Test", noquote ("print ('hi')")))
// makeHeaderCode ("SimpleAnova", new Array ("Model", "Data"))
- echo ('rk.echo (result)');
+ echo ('rk.echo (result)\n');
+
+ echo ('### i18n tests below ###\n');
+ echo ('print (' + i18n ("This is an i18n text") + ')\n');
+ echo ('# A comment: ' + i18nc ("Dummy context", noquote ("This is a non-auto-quoted i18n'ed text with context")) + '\n');
+ for (var i = 10; i > 0; --i) {
+ echo ('print (' + i18np ("There was one green bottle standing on the %2", "There were %1 green bottles standing on the %2", i, i18n (noquote ("wall"))) + ')\n');
+ }
+ for (var i = 10; i > 0; --i) {
+ echo ('print (' + i18ncp ("Dummy context", "There was one contextualized %2 bottle standing on the %3", "There were %1 contextualized %2 bottles standing on the %3", i, i18n (noquote ("green")), i18n (noquote ("wall"))) + ')\n');
+ }
}
Modified: trunk/rkward/rkward/plugins/testing/test1.xml
===================================================================
--- trunk/rkward/rkward/plugins/testing/test1.xml 2014-11-03 16:15:18 UTC (rev 4986)
+++ trunk/rkward/rkward/plugins/testing/test1.xml 2014-11-03 19:30:57 UTC (rev 4987)
@@ -7,7 +7,7 @@
<script><![CDATA[
call_num = 0;
last_command_id = -1;
- gui.setValue ("text.text", i18n ("Select a dependent variable!"));
+ gui.setValue ("text.text", i18n (noquote ("Select a dependent variable!")));
/*f = Kross.module('forms');
label = f.createWidget(scripty, 'QLabel', 'Label', {});
Modified: trunk/rkward/rkward/scriptbackends/qtscripti18n.h
===================================================================
--- trunk/rkward/rkward/scriptbackends/qtscripti18n.h 2014-11-03 16:15:18 UTC (rev 4986)
+++ trunk/rkward/rkward/scriptbackends/qtscripti18n.h 2014-11-03 19:30:57 UTC (rev 4987)
@@ -34,11 +34,11 @@
Q_INVOKABLE QString i18nc (const QString &msgctxt, const QString &msgid) const {
return (catalog->translate (msgctxt, msgid));
};
- Q_INVOKABLE QString i18np (const QString &msgid_singular, const QString &msgid_plural, unsigned long int count) const {
+ Q_INVOKABLE QString i18np (const QString &msgid_singular, const QString &msgid_plural, uint count) const {
return (catalog->translate (msgid_singular, msgid_plural, count));
};
- Q_INVOKABLE QString i18ncp (const QString &msgctxt, const QString &msgid_singular, const QString &msgid_plural, unsigned long int count) const {
- return (catalog->translate (msgctxt, msgid_singular, msgid_plural, count).arg (count));
+ Q_INVOKABLE QString i18ncp (const QString &msgctxt, const QString &msgid_singular, const QString &msgid_plural, uint count) const {
+ return (catalog->translate (msgctxt, msgid_singular, msgid_plural, count));
};
/** Add an RKMessageCatalog, and the required glue code to the given QScriptEngine. */
static void addI18nToScriptEngine (QScriptEngine *engine, const RKMessageCatalog *catalog);
More information about the rkward-tracker
mailing list