aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-13 19:24:53 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-06-13 19:29:35 +0200
commit6315130e60ae44c4d6c5bac8d83732462b03dfea (patch)
tree6bdeb5d19371f53ef37c9039d3eace845b88e847
parent39cf857db9b926c47f545cba1d7113267260c40e (diff)
Internationalization -- conversion of strings from bitcoin core
-rw-r--r--bitcoin-qt.pro3
-rwxr-xr-xscripts/extract_strings_qt.py63
-rw-r--r--src/qt/bitcoinstrings.cpp86
3 files changed, 151 insertions, 1 deletions
diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro
index ab5ddadd14..c7b7ff954b 100644
--- a/bitcoin-qt.pro
+++ b/bitcoin-qt.pro
@@ -94,7 +94,8 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/optionsmodel.cpp \
src/qt/monitoreddatamapper.cpp \
src/qt/transactiondesc.cpp \
- src/qt/transactiondescdialog.cpp
+ src/qt/transactiondescdialog.cpp \
+ src/qt/bitcoinstrings.cpp
RESOURCES += \
src/qt/bitcoin.qrc
diff --git a/scripts/extract_strings_qt.py b/scripts/extract_strings_qt.py
new file mode 100755
index 0000000000..56f47654c1
--- /dev/null
+++ b/scripts/extract_strings_qt.py
@@ -0,0 +1,63 @@
+#!/usr/bin/python
+'''
+Extract _("...") strings for translation and convert to Qt4 stringdefs so that
+they can be picked up by Qt linguist.
+'''
+from subprocess import Popen, PIPE
+
+OUT_CPP="src/qt/bitcoinstrings.cpp"
+EMPTY=['""']
+
+def parse_po(text):
+ """
+ Parse 'po' format produced by xgettext.
+ Return a list of (msgid,msgstr) tuples.
+ """
+ messages = []
+ msgid = []
+ msgstr = []
+ in_msgid = False
+ in_msgstr = False
+
+ for line in text.split('\n'):
+ line = line.rstrip('\r')
+ if line.startswith('msgid '):
+ if in_msgstr:
+ messages.append((msgid, msgstr))
+ in_msgstr = False
+ # message start
+ in_msgid = True
+
+ msgid = [line[6:]]
+ elif line.startswith('msgstr '):
+ in_msgid = False
+ in_msgstr = True
+ msgstr = [line[7:]]
+ elif line.startswith('"'):
+ if in_msgid:
+ msgid.append(line)
+ if in_msgstr:
+ msgstr.append(line)
+
+ if in_msgstr:
+ messages.append((msgid, msgstr))
+
+ return messages
+
+files = ['src/base58.h', 'src/bignum.h', 'src/db.cpp', 'src/db.h', 'src/externui.h', 'src/headers.h', 'src/init.cpp', 'src/init.h', 'src/irc.cpp', 'src/irc.h', 'src/key.h', 'src/main.cpp', 'src/main.h', 'src/net.cpp', 'src/net.h', 'src/noui.h', 'src/rpc.cpp', 'src/rpc.h', 'src/script.cpp', 'src/script.h', 'src/serialize.h', 'src/strlcpy.h', 'src/uint256.h', 'src/util.cpp', 'src/util.h']
+
+# xgettext -n --keyword=_ $FILES
+child = Popen(['xgettext','--output=-','-n','--keyword=_'] + files, stdout=PIPE)
+(out, err) = child.communicate()
+
+messages = parse_po(out)
+
+f = open(OUT_CPP, 'w')
+f.write('#include <QtGlobal>\n')
+f.write('// Automatically generated by extract_strings.py\n')
+f.write('static const char *bitcoin_strings[] = {')
+for (msgid, msgstr) in messages:
+ if msgid != EMPTY:
+ f.write('QT_TRANSLATE_NOOP("bitcoin-core", %s),\n' % ('\n'.join(msgid)))
+f.write('};')
+f.close()
diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp
new file mode 100644
index 0000000000..2fa8de052b
--- /dev/null
+++ b/src/qt/bitcoinstrings.cpp
@@ -0,0 +1,86 @@
+#include <QtGlobal>
+// Automatically generated by extract_strings.py
+static const char *bitcoin_strings[] = {QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin version"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or bitcoind\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "List commands\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Options:\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Specify configuration file (default: bitcoin.conf)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Specify pid file (default: bitcoind.pid)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Generate coins\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Don't generate coins\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Start minimized\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Specify data directory\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Specify connection timeout (in milliseconds)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks4 proxy\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for addnode and connect\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Don't accept connections from outside\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Don't attempt to use UPnP to map the listening port\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to use UPnP to map the listening port\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Listen for JSON-RPC connections on <port> (default: 8332)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on <ip> (default: 127.0.0.1)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to <n> (default: 100)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"\n"
+"SSL options: (see the Bitcoin Wiki for SSL setup instructions)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:"
+"@STRENGTH)\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "This help message\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Cannot obtain a lock on data directory %s. Bitcoin is probably already "
+"running."),
+QT_TRANSLATE_NOOP("bitcoin-core", "Error loading addr.dat \n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Error loading blkindex.dat \n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat \n"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -paytxfee=<amount>"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Warning: -paytxfee is set very high. This is the transaction fee you will "
+"pay if you send a transaction."),
+QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Disk space is low "),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Error: This transaction requires a transaction fee of at least %s because of "
+"its amount, complexity, or use of recently received funds "),
+QT_TRANSLATE_NOOP("bitcoin-core", "Error: Transaction creation failed "),
+QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Error: The transaction was rejected. This might happen if some of the coins "
+"in your wallet were already spent, such as if you used a copy of wallet.dat "
+"and coins were spent in the copy but not marked as spent here."),
+QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"),
+QT_TRANSLATE_NOOP("bitcoin-core", "Invalid bitcoin address"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Unable to bind to port %d on this computer. Bitcoin is probably already "
+"running."),
+QT_TRANSLATE_NOOP("bitcoin-core", "To use the %s option"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Warning: %s, you must set rpcpassword=<password>\n"
+"in the configuration file: %s\n"
+"If the file does not exist, create it with owner-readable-only file "
+"permissions.\n"),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"You must set rpcpassword=<password> in the configuration file:\n"
+"%s\n"
+"If the file does not exist, create it with owner-readable-only file "
+"permissions."),
+QT_TRANSLATE_NOOP("bitcoin-core", ""
+"Warning: Please check that your computer's date and time are correct. If "
+"your clock is wrong Bitcoin will not work properly."),
+QT_TRANSLATE_NOOP("bitcoin-core", "-beta"),
+}; \ No newline at end of file