[PyQt] [i18n] Can't understand contexts
Andreas Pakulat
apaku at gmx.de
Sat Jul 18 15:10:50 BST 2009
On 18.07.09 18:28:39, Anonymous wrote:
> Hi,
>
> I develop my application using PyQt4.
>
> First I've decided to put all messages those are subject to be
> translated into a separate file, let's call it msg.py like:
>
> ADD_ACTION = QCoreApplication.translate('here goes context', 'Add', '', 1)
> # ...
>
> and etc. and init QApplication and setup translators in main source
> file before import-ing msg.py.
>
> Is it possible to put something as context argument so translations
> will actually work for all classes or is there any way to disable
> context chack?
Context is just a string that allows you to differentiate between the
same string being used in different places of your application.
Sometimes these differing places need different translations in some
languages, hence the translator needs a context. For proper translation
appearing in the GUI there shouldn't be anything you need to do. lupdate
should extract the messages including the custom context into the .ts
file and there it'll appear for the translator to use.
> P.S. Even when I put class name for class that exists in main source
> file and is already declared into context arg, e. g. "QtInterface"
> or "AddAction" anything doesn't get translated.
Hmm, strange, works fine here with the attached three files (C++
though). Can you post a minimal example?
(To run the example put all three files into a directory, then do qmake;
make; lrelease testtrans.pro)
Andreas
--
You will live a long, healthy, happy life and make bags of money.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.ts
Type: text/texmacs
Size: 300 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090718/0a3beb92/foo.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 369 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090718/0a3beb92/main.bin
-------------- next part --------------
######################################################################
# Automatically generated by qmake (2.01a) Sat Jul 18 16:06:31 2009
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
SOURCES += main.cpp
TRANSLATIONS += foo.ts
More information about the PyQt
mailing list