Results 1 to 20 of 25

Thread: How to tranlaste #define and text from file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    The translation mark is outside a context. Either put it in a context or use QT_TRANSLATE_NOOP instead of QT_TR_NOOP passing a context to the call. Make sure the same context is used with the tr() call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    stevocz (17th December 2013)

  3. #2
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    can you fix it and send me back this application?

    because i am try this:

    const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("translateCategory", "Translate");

    and "Translate" is in .ts file, but in application text isn't changed.

    and please fix QDialogButtonBox

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: How to tranlaste #define and text from file

    maybe a stupid question, but why translate the QDialogButtonBox strings again?

    Those strings from Qt should already be translate for Qt.
    If they aren't, maybe the Qt translation catalogue wasn't loaded?
    See http://qt-project.org/doc/qt-4.8/i18...ng-translation

    Cheers,
    _

  5. #4
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    when i am erased .ts file and create new, QT_TRANSLATE_NOOP works ok

    this

    const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("translateCategory", "translate");
    ui.label_2->setText(QApplication::translate("translateCategor y",TEXT_TO_TRANSLATE));

    and this

    const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("QObject", "translate");
    ui.label_2->setText(QObject::tr(TEXT_TO_TRANSLATE));

    booth work.



    or best for this example

    const char * const TEXT_TO_TRANSLATE = QT_TRANSLATE_NOOP("MainWindow", "translate");
    ui.label_2->setText(tr(TEXT_TO_TRANSLATE));

    work too.
    Last edited by stevocz; 17th December 2013 at 14:28.

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    Quote Originally Posted by stevocz View Post
    and "Translate" is in .ts file, but in application text isn't changed.
    Did you modify the respective tr() call to take data from the "translateCategory" context?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #6
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    yes, tr() is modified and works. now i must edit QDialogButtonBox.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    Quote Originally Posted by stevocz View Post
    yes, tr() is modified and works. now i must edit QDialogButtonBox.
    No, you just have to load the bundled message catalog for it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #8
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    but how? i am tried load QLibraryInfo but doesnt work

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    What does QLibraryInfo have to do with this??? You are supposed to install a translator on your application using Qt's message catalog that resides in the translations subdirectory of your Qt installation.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #10
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    and how do it?

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    The same as you do it with any other translator -- you load the message catalog and install the translator on the application.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. The following user says thank you to wysota for this useful post:

    stevocz (18th December 2013)

  14. #12
    Join Date
    May 2013
    Posts
    45
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: How to tranlaste #define and text from file

    thank this works, but there are only few languages. how add my language?
    Last edited by stevocz; 18th December 2013 at 07:44.

  15. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to tranlaste #define and text from file

    TS files for Qt are available. You can provide your own translations using Linguist or search the web if an external catalog for your language is available.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. The following user says thank you to wysota for this useful post:

    stevocz (18th December 2013)

Similar Threads

  1. How to define a string marco in pro file
    By jevonwang in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 6th May 2013, 05:49
  2. QMake how to define install target of lib in the .pro file
    By thgis in forum Qt Tools
    Replies: 1
    Last Post: 15th April 2013, 12:59
  3. How to define a string in a .pro file
    By ChristineD in forum Newbie
    Replies: 4
    Last Post: 16th October 2012, 17:14
  4. qmake rc file define version
    By cafu1007 in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2012, 16:38
  5. Replies: 1
    Last Post: 3rd September 2008, 14:16

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
  •  
Qt is a trademark of The Qt Company.