Merge pull request #2996 from theuni/qt-translation

Update translation process for autotools
This commit is contained in:
Gavin Andresen 2013-09-14 16:17:27 -07:00
commit 2975db76b3
5 changed files with 49 additions and 23 deletions

View File

@ -147,8 +147,10 @@ AC_PATH_PROGS([MOC], [moc-qt4 moc4 moc],, $qt_bin_path:$PATH)
AC_PATH_PROGS([UIC], [uic-qt4 uic4 uic],, $qt_bin_path:$PATH) AC_PATH_PROGS([UIC], [uic-qt4 uic4 uic],, $qt_bin_path:$PATH)
AC_PATH_PROGS([RCC], [rcc-qt4 rcc4 rcc],, $qt_bin_path:$PATH) AC_PATH_PROGS([RCC], [rcc-qt4 rcc4 rcc],, $qt_bin_path:$PATH)
AC_PATH_PROGS([LRELEASE], [lrelease-qt4 lrelease4 lrelease],, $qt_bin_path:$PATH) AC_PATH_PROGS([LRELEASE], [lrelease-qt4 lrelease4 lrelease],, $qt_bin_path:$PATH)
AC_PATH_PROGS([LUPDATE], [lupdate-qt4 lupdate4 lupdate],, $qt_bin_path:$PATH)
AC_PATH_PROG([PROTOC], [protoc],, $protoc_bin_path:$PATH) AC_PATH_PROG([PROTOC], [protoc],, $protoc_bin_path:$PATH)
AC_PATH_PROG(CCACHE,ccache) AC_PATH_PROG(CCACHE,ccache)
AC_PATH_PROG(XGETTEXT,xgettext)
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
## TODO: Remove these hard-coded paths and flags. They are here for the sake of ## TODO: Remove these hard-coded paths and flags. They are here for the sake of
@ -625,6 +627,13 @@ if test x$use_qt = xyes; then
AC_MSG_ERROR("libQtDBus not found. Use --without-qtdbus.") AC_MSG_ERROR("libQtDBus not found. Use --without-qtdbus.")
fi fi
fi fi
if test x$XGETTEXT == x; then
AC_MSG_WARN("xgettext is required to update qt translations")
fi
if test x$LUPDATE == x; then
AC_MSG_WARN("lupdate is required to update qt translations")
fi
BUILD_QT=qt BUILD_QT=qt
else else
use_qt=no use_qt=no

View File

@ -32,14 +32,13 @@ This directory contains all translations. Filenames must adhere to this format:
`src/qt/locale/bitcoin_en.ts` is treated in a special way. It is used as the `src/qt/locale/bitcoin_en.ts` is treated in a special way. It is used as the
source for all other translations. Whenever a string in the code is changed source for all other translations. Whenever a string in the code is changed
this file must be updated to reflect those changes. This can be accomplished this file must be updated to reflect those changes. A custom script is used
by running `lupdate` (included in the Qt SDK). Also, a custom script is used
to extract strings from the non-Qt parts. This script makes use of `gettext`, to extract strings from the non-Qt parts. This script makes use of `gettext`,
so make sure that utility is installed (ie, `apt-get install gettext` on so make sure that utility is installed (ie, `apt-get install gettext` on
Ubuntu/Debian): Ubuntu/Debian). Once this has been updated, lupdate (included in the Qt SDK)
is used to update bitcoin_en.ts. This process has been automated, from src/qt,
python share/qt/extract_strings_qt.py simply run:
lupdate bitcoin-qt.pro -no-obsolete -locations relative -ts src/qt/locale/bitcoin_en.ts make translate
##### Handling of plurals in the source file ##### Handling of plurals in the source file

View File

@ -6,6 +6,7 @@ they can be picked up by Qt linguist.
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
import glob import glob
import operator import operator
import os
OUT_CPP="src/qt/bitcoinstrings.cpp" OUT_CPP="src/qt/bitcoinstrings.cpp"
EMPTY=['""'] EMPTY=['""']
@ -49,7 +50,8 @@ def parse_po(text):
files = glob.glob('src/*.cpp') + glob.glob('src/*.h') files = glob.glob('src/*.cpp') + glob.glob('src/*.h')
# xgettext -n --keyword=_ $FILES # xgettext -n --keyword=_ $FILES
child = Popen(['xgettext','--output=-','-n','--keyword=_'] + files, stdout=PIPE) XGETTEXT=os.getenv('XGETTEXT', 'gettext')
child = Popen([XGETTEXT,'--output=-','-n','--keyword=_'] + files, stdout=PIPE)
(out, err) = child.communicate() (out, err) = child.communicate()
messages = parse_po(out) messages = parse_po(out)

View File

@ -58,6 +58,10 @@ leveldb/libmemenv.a:
@echo "Building LevelDB ..." && cd leveldb && CXX="$(CXX)" CC="$(CC)" \ @echo "Building LevelDB ..." && cd leveldb && CXX="$(CXX)" CC="$(CC)" \
PLATFORM=$(TARGET_OS) AR="$(AR)" $(MAKE) $(LEVELDB_TARGET_FLAGS) OPT="$(CXXFLAGS) $(CPPFLAGS)" libmemenv.a PLATFORM=$(TARGET_OS) AR="$(AR)" $(MAKE) $(LEVELDB_TARGET_FLAGS) OPT="$(CXXFLAGS) $(CPPFLAGS)" libmemenv.a
qt/bitcoinstrings.cpp: $(libbitcoin_a_SOURCES)
@test -n $(XGETTEXT) || echo "xgettext is required for updating translations"
@cd $(top_srcdir); XGETTEXT=$(XGETTEXT) share/qt/extract_strings_qt.py
CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno
DISTCLEANFILES = obj/build.h DISTCLEANFILES = obj/build.h

View File

@ -53,6 +53,9 @@ QT_MOC_CPP = moc_aboutdialog.cpp moc_addressbookpage.cpp \
moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \ moc_transactiontablemodel.cpp moc_transactionview.cpp moc_walletframe.cpp \
moc_walletmodel.cpp moc_walletstack.cpp moc_walletview.cpp moc_walletmodel.cpp moc_walletstack.cpp moc_walletview.cpp
BITCOIN_MM = macdockiconhandler.mm macnotificationhandler.mm
QR_CPP = qrcodedialog.cpp
QT_MOC = intro.moc overviewpage.moc rpcconsole.moc QT_MOC = intro.moc overviewpage.moc rpcconsole.moc
QT_QRC_CPP = qrc_bitcoin.cpp QT_QRC_CPP = qrc_bitcoin.cpp
@ -91,6 +94,19 @@ RES_ICONS = res/icons/bitcoin.png res/icons/address-book.png \
res/icons/qrcode.png res/icons/debugwindow.png res/icons/bitcoin.ico \ res/icons/qrcode.png res/icons/debugwindow.png res/icons/bitcoin.ico \
res/icons/bitcoin_testnet.ico res/icons/bitcoin_testnet.ico
BITCOIN_QT_CPP = aboutdialog.cpp addressbookpage.cpp \
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp \
bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp editaddressdialog.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \
rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \
signverifymessagedialog.cpp splashscreen.cpp transactiondesc.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \
walletmodel.cpp walletmodeltransaction.cpp walletstack.cpp walletview.cpp
RES_IMAGES = res/images/about.png res/images/splash.png \ RES_IMAGES = res/images/about.png res/images/splash.png \
res/images/splash_testnet.png res/images/splash_testnet.png
@ -100,20 +116,8 @@ BITCOIN_RC = res/bitcoin-qt-res.rc
libbitcoinqt_a_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) \ libbitcoinqt_a_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) \
-I$(top_srcdir)/src/qt/forms $(QT_DBUS_INCLUDES) -I$(top_srcdir)/src/qt/forms $(QT_DBUS_INCLUDES)
libbitcoinqt_a_SOURCES = aboutdialog.cpp addressbookpage.cpp \ libbitcoinqt_a_SOURCES = $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(QT_FORMS_UI) \
addresstablemodel.cpp askpassphrasedialog.cpp bitcoinaddressvalidator.cpp \ $(QT_QRC) $(QT_TS) $(PROTOBUF_PROTO) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES)
bitcoinamountfield.cpp bitcoin.cpp bitcoingui.cpp bitcoinstrings.cpp \
bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp editaddressdialog.cpp \
guiutil.cpp intro.cpp monitoreddatamapper.cpp notificator.cpp \
optionsdialog.cpp optionsmodel.cpp overviewpage.cpp paymentrequestplus.cpp \
paymentserver.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp \
rpcconsole.cpp sendcoinsdialog.cpp sendcoinsentry.cpp \
signverifymessagedialog.cpp splashscreen.cpp transactiondesc.cpp \
transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp \
transactiontablemodel.cpp transactionview.cpp walletframe.cpp \
walletmodel.cpp walletmodeltransaction.cpp walletstack.cpp walletview.cpp \
$(BITCOIN_QT_H) $(QT_FORMS_UI) $(QT_QRC) $(QT_TS) $(PROTOBUF_PROTO) \
$(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES)
nodist_libbitcoinqt_a_SOURCES = $(QT_MOC_CPP) $(QT_MOC) $(PROTOBUF_CC) \ nodist_libbitcoinqt_a_SOURCES = $(QT_MOC_CPP) $(QT_MOC) $(PROTOBUF_CC) \
$(PROTOBUF_H) $(QT_QRC_CPP) $(PROTOBUF_H) $(QT_QRC_CPP)
@ -126,13 +130,13 @@ $(QT_MOC): $(PROTOBUF_H)
$(QT_MOC_CPP): $(PROTOBUF_H) $(QT_MOC_CPP): $(PROTOBUF_H)
if TARGET_DARWIN if TARGET_DARWIN
libbitcoinqt_a_SOURCES += macdockiconhandler.mm macnotificationhandler.mm libbitcoinqt_a_SOURCES += $(BITCOIN_MM)
endif endif
if TARGET_WINDOWS if TARGET_WINDOWS
libbitcoinqt_a_SOURCES += $(BITCOIN_RC) libbitcoinqt_a_SOURCES += $(BITCOIN_RC)
endif endif
if USE_QRCODE if USE_QRCODE
libbitcoinqt_a_SOURCES += qrcodedialog.cpp libbitcoinqt_a_SOURCES += $(QR_CPP)
endif endif
# #
@ -149,8 +153,16 @@ QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI:
#locale/foo.ts -> locale/foo.qm #locale/foo.ts -> locale/foo.qm
QT_QM=$(QT_TS:.ts=.qm) QT_QM=$(QT_TS:.ts=.qm)
.PHONY: FORCE
.SECONDARY: $(QT_QM) .SECONDARY: $(QT_QM)
bitcoinstrings.cpp: FORCE
$(MAKE) -C $(top_srcdir)/src qt/bitcoinstrings.cpp
translate: bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM) $(QR_CPP)
@test -n $(LUPDATE) || echo "lupdate is required for updating translations"
@$(LUPDATE) $^ -locations relative -no-obsolete -ts locale/bitcoin_en.ts
$(QT_QRC_CPP): $(QT_QRC) $(QT_QM) $(QT_FORMS_H) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES) $(PROTOBUF_H) $(QT_QRC_CPP): $(QT_QRC) $(QT_QM) $(QT_FORMS_H) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES) $(PROTOBUF_H)
@cd $(abs_srcdir); test -f $(RCC) && $(RCC) -name bitcoin -o $(abs_builddir)/$@ $< || \ @cd $(abs_srcdir); test -f $(RCC) && $(RCC) -name bitcoin -o $(abs_builddir)/$@ $< || \
echo error: could not build $@ echo error: could not build $@