Results 1 to 14 of 14

Thread: How to stop lupdate from generating duplicate strings?

  1. #1
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to stop lupdate from generating duplicate strings?

    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.

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: How to stop lupdate from generating duplicate strings?

    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.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to stop lupdate from generating duplicate strings?

    And the form is not listed twice in the .pro file? Or do you mean dropping the obsolete translations with -noobsolete?
    J-P Nurmi

  4. #4
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    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.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to stop lupdate from generating duplicate strings?

    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.
    J-P Nurmi

  6. #6
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    How can this be done?

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

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to stop lupdate from generating duplicate strings?

    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).
    J-P Nurmi

  8. #8
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    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?

  9. #9
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    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.

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to stop lupdate from generating duplicate strings?

    Quote Originally Posted by Vadi View Post
    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).
    J-P Nurmi

  11. #11
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    Hmm. I replaced my

    Qt Code:
    1. tr("message")
    To copy to clipboard, switch view to plain text mode 

    With

    QCoreApplication::translate("mudlet", "message", NULL, QCoreApplication::UnicodeUTF8)
    However lupdate is not picking up these strings now.

  12. #12
    Join Date
    May 2008
    Posts
    155
    Thanked 15 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to stop lupdate from generating duplicate strings?

    Quote Originally Posted by Vadi View Post
    Hmm. I replaced my

    Qt Code:
    1. tr("message")
    To copy to clipboard, switch view to plain text mode 

    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

    Qt Code:
    1. QTextCodec::setCodecForTr()
    To copy to clipboard, switch view to plain text mode 

    and a simple

    Qt Code:
    1. QApplication::translate("...", "...")
    To copy to clipboard, switch view to plain text mode 

  13. #13
    Join Date
    May 2008
    Posts
    155
    Thanked 15 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to stop lupdate from generating duplicate strings?

    Quote Originally Posted by Vadi View Post
    ...
    Any possible ideas for this?
    That does not really look like a .ts file. How do you create it?

  14. #14
    Join Date
    Sep 2008
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to stop lupdate from generating duplicate strings?

    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.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.