PDA

View Full Version : How to stop lupdate from generating duplicate strings?



Vadi
24th January 2009, 14:33
Hi,

I'm having a serious issue with lupdate - it is generating duplicate strings when it parses the .ui designer files.

Is there any way to make it not to? I didn't see an option for this to give to lupdate or this being documented.

janus
24th January 2009, 14:49
Hi,

I suppose you can not change this behaviour. But when you use Linguist you have an option to select previously entered translations. Then its pretty fast even if you have got several duplicate strings.

jpn
24th January 2009, 14:49
And the form is not listed twice in the .pro file? Or do you mean dropping the obsolete translations with -noobsolete?

Vadi
24th January 2009, 15:38
I'm not going to be making use of the Linguist for translations, so duplicate strings are an issue for me :|

I did try lupdate -noobsolete, but that gave the same result. The duplicate strings come from the different .ui files.

jpn
24th January 2009, 17:11
Ah you mean like that. Yes, if you have two different forms with different names, they are treated as different translation contexts. Give both forms the same name and they will be treated as same translation context.

Vadi
25th January 2009, 03:38
How can this be done?

It seems the designer only accepts one window per .ui file.

jpn
25th January 2009, 09:14
Make both forms have the same name eg. "Form" (it's the objectName-property when you select the form background or the root from the object inspector).

Vadi
25th January 2009, 21:03
Thanks, I found the issue with "Forms" being duplicated as the window title (they were actually embedded, so never saw the title).

I still have the problem though, but on a lesser scale - it's duplicating other strings too:


#: MainWindow#4
msgid "Triggers"
msgstr ""

#: dlgTriggerEditor#1
msgid "Triggers"
msgstr ""

#: trigger_editor#11
msgid "Triggers"
msgstr ""

Any possible ideas for this?

Vadi
25th January 2009, 21:22
Naming all of the objectNames the same temporarily solved duplication between .ui files - however, it doesn't account for the duplicates between .cpp and .ui files still.

jpn
25th January 2009, 21:39
Naming all of the objectNames the same temporarily solved duplication between .ui files - however, it doesn't account for the duplicates between .cpp and .ui files still.
You can use QCoreApplication::translate() instead of QObject::tr() in .cpp files to enforce a certain translation context (the same as in the .ui file).

Vadi
6th February 2009, 03:44
Hmm. I replaced my


tr("message")

With


QCoreApplication::translate("mudlet", "message", NULL, QCoreApplication::UnicodeUTF8)

However lupdate is not picking up these strings now.

ktk
6th February 2009, 22:12
Hmm. I replaced my


tr("message")

With



However lupdate is not picking up these strings now.

lupdate does not contain a full C++ parser, so it is somewhat limited in
what it accepts.

Try using


QTextCodec::setCodecForTr()

and a simple


QApplication::translate("...", "...")

ktk
6th February 2009, 22:15
...
Any possible ideas for this?

That does not really look like a .ts file. How do you create it?

Vadi
6th February 2009, 22:27
Thanks, I'll give that a try.

And the example provided was a .po file that I converted the .ts to, sorry. But in the .ts it showed the different contexts anyway.